You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optimize experimental_python_types and add type-mapping tests
Instead of checking the type for each row, check the type once for each
fetch() call and compute a list of lambdas which are to be applied to
the values from each row. A new RowMapperFactory class is created to
wrap this behavior.
The experimental_python_types flag is now processed in the TrinoQuery
class instead of the TrinoResult class.
Type mapping tests for each lambda which maps rows to Python types is
added.
Copy file name to clipboardExpand all lines: README.md
+52-7
Original file line number
Diff line number
Diff line change
@@ -383,12 +383,12 @@ exits the *with* context and the queries succeed, otherwise
383
383
384
384
## Improved Python types
385
385
386
-
If you enable the flag `experimental_python_types`, the client will convert the results of the query to the
386
+
If you enable the flag `experimental_python_types`, the client will convert the results of the query to the
387
387
corresponding Python types. For example, if the query returns a `DECIMAL` column, the result will be a `Decimal`object.
388
388
389
-
Limitations of the Python types are described in the
390
-
[Python types documentation](https://docs.python.org/3/library/datatypes.html). These limitations will generate an
391
-
exception `trino.exceptions.DataError`if the query returns a value that cannot be converted to the corresponding Python
389
+
Limitations of the Python types are described in the
390
+
[Python types documentation](https://docs.python.org/3/library/datatypes.html). These limitations will generate an
391
+
exception `trino.exceptions.DataError`if the query returns a value that cannot be converted to the corresponding Python
392
392
type.
393
393
394
394
```python
@@ -418,6 +418,7 @@ assert cur.description[0][1] == "timestamp with time zone"
418
418
419
419
Start by forking the repository and then modify the code in your fork.
420
420
421
+
<<<<<<<HEAD
421
422
We recommend that you use Python3's `venv` for development:
422
423
423
424
```
@@ -430,6 +431,16 @@ With `-e` passed to `pip install` above pip can reference the code you are
430
431
modifying in the *virtual env*. That way, you do not need to run `pip install`
431
432
again to make your changes applied to the *virtual env*.
432
433
434
+
=======
435
+
Clone the repository and go inside the code directory.
436
+
437
+
Python dependencies are managed using [Poetry](https://python-poetry.org/) which helps to ensure the project is managed in a deterministic way. Poetry [creates a virtual environment](https://python-poetry.org/docs/managing-environments/) to aid with the process. Poetry should be installed via:
>>>>>>>1226d39 ([CI] Migrate to pyproject.toml and poetry for deterministic builds)
433
444
When the code is ready, submit a Pull Request.
434
445
435
446
### Code style
@@ -443,25 +454,37 @@ Most of them also apply to code in trino-python-client.
443
454
444
455
### Running tests
445
456
446
-
`trino-python-client` uses [pytest](https://pytest.org/) for its tests. To run
457
+
`trino-python-client` uses [tox](https://tox.wiki/en/latest/)—a tool for standardizing testing in Python—which leverages the [pytest](https://pytest.org/) testing framework. To run
447
458
only unit tests, type:
448
459
449
460
```
450
-
$pytest tests/unit
461
+
$poetry run tox -e <environment>-- tests/unit
451
462
```
452
463
464
+
Similarly to run only integration tests, type:
465
+
466
+
```
467
+
$ poetry run tox -e <environment>-- tests/integration
468
+
```
469
+
470
+
where `<environment>` denotes the Python environment (see the configuration in`tox.ini`).
471
+
453
472
Then you can pass options like `--pdb`or anything supported by `pytest --help`.
454
473
474
+
<<<<<<<HEAD
455
475
To run integration tests:
456
476
457
477
```
458
478
$ pytest tests/integration
459
479
```
460
480
481
+
=======
482
+
>>>>>>>1226d39 ([CI] Migrate to pyproject.toml and poetry for deterministic builds)
461
483
They pull a Docker image and then run a container with a Trino server:
462
484
- the image is named `trinodb/trino:${TRINO_VERSION}`
463
485
- the container is named `trino-python-client-tests-{uuid4()[:7]}`
464
486
487
+
<<<<<<<HEAD
465
488
To run the tests with different versions of Python in managed *virtual envs*,
466
489
use `tox` (see the configuration in`tox.ini`):
467
490
@@ -470,13 +493,30 @@ $ tox
470
493
```
471
494
472
495
## Releasing
496
+
=======
497
+
### pre-commit
498
+
499
+
`trino-python-client` leverages [pre-commit](https://pre-commit.com/) to help identify simple issues before submission to code review. Checks include the validity of the `pyproject.toml`file, type checks via [Mypy](https://github.com/python/mypy), etc. To enable `pre-commit` run:
500
+
501
+
```
502
+
poetry run pre-commit install
503
+
```
504
+
505
+
which will run on every commit. You can also run it anytime using:
506
+
507
+
```
508
+
poetry run tox -e pre-commit
509
+
```
510
+
511
+
### Releasing
512
+
>>>>>>>1226d39 ([CI] Migrate to pyproject.toml and poetry for deterministic builds)
473
513
474
514
- [Set up your development environment](#Getting-Started-With-Development).
475
515
- Check the local workspace is up to date and has no uncommitted changes
476
516
```bash
477
517
git fetch -a && git status
478
518
```
479
-
- Change version in`trino/__init__.py` to a new version, e.g. `0.123.0`.
519
+
- Change version in`trino/pyproject.toml` to a new version, e.g. `0.123.0`.
480
520
- Commit
481
521
```bash
482
522
git commit -a -m "Bump version to 0.123.0"
@@ -487,12 +527,17 @@ $ tox
487
527
```
488
528
- Create release package and upload it to PyPI
489
529
```bash
530
+
<<<<<<<HEAD
490
531
. .venv/bin/activate && \
491
532
pip install twine && \
492
533
rm -rf dist/&& \
493
534
./setup.py sdist bdist_wheel && \
494
535
twine upload dist/*&& \
495
536
open https://pypi.org/project/trino/&& \
537
+
=======
538
+
poetry publish --build &&
539
+
open https://pypi.org/project/trino/&&
540
+
>>>>>>>1226d39 ([CI] Migrate to pyproject.toml and poetry for deterministic builds)
0 commit comments