trinodb / trino-python-client

Python client for Trino
Apache License 2.0
311 stars 154 forks source link

Optimize the experimental python types flag #206

Closed lpoulain closed 1 year ago

lpoulain commented 2 years ago

Optimizes the experimental_python_types flag. 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.

hashhar commented 1 year ago

@lpoulain Can you squash the "fixups" together?

lpoulain commented 1 year ago

@hashhar done

hashhar commented 1 year ago

@lpoulain "All commits" do not need to be squashed. Just the logically related ones.

For future PRs see https://github.com/trinodb/trino/blob/master/.github/DEVELOPMENT.md#git-merge-strategy

hashhar commented 1 year ago

@lpoulain Please reword the commit message as:

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.
lpoulain commented 1 year ago

Looks good but please reword commit message to have useful information.

@hashhar done