Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Presto column_type_mappings time and timestamp #12861

Merged
merged 2 commits into from
Feb 1, 2021

Conversation

rmgpinto
Copy link

@rmgpinto rmgpinto commented Feb 1, 2021

SUMMARY

Presto has incorrect order of column type mappings.
timestamp is overriden with time due to these lines:

(re.compile(r"^time.*", re.IGNORECASE), types.Time()),
(re.compile(r"^timestamp.*", re.IGNORECASE), types.TIMESTAMP())

causing incorrect query statement to be passed from superset to presto.

TEST PLAN

Proposed solutions swaps those lines.

ADDITIONAL INFORMATION

@rmgpinto rmgpinto changed the title Fix presto column_type_mappings time and timestamp fix: presto column_type_mappings time and timestamp Feb 1, 2021
@rmgpinto rmgpinto changed the title fix: presto column_type_mappings time and timestamp fix: Presto column_type_mappings time and timestamp Feb 1, 2021
Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Would you mind adding a unit test for this?

def test_get_sqla_column_type(self):
sqla_type = PrestoEngineSpec.get_sqla_column_type("varchar(255)")
assert isinstance(sqla_type, types.VARCHAR)
assert sqla_type.length == 255
sqla_type = PrestoEngineSpec.get_sqla_column_type("varchar")
assert isinstance(sqla_type, types.String)
assert sqla_type.length is None
sqla_type = PrestoEngineSpec.get_sqla_column_type("char(10)")
assert isinstance(sqla_type, types.CHAR)
assert sqla_type.length == 10
sqla_type = PrestoEngineSpec.get_sqla_column_type("char")
assert isinstance(sqla_type, types.CHAR)
assert sqla_type.length is None
sqla_type = PrestoEngineSpec.get_sqla_column_type("integer")
assert isinstance(sqla_type, types.Integer)
sqla_type = PrestoEngineSpec.get_sqla_column_type(None)
assert sqla_type is None

@villebro villebro merged commit 51195af into apache:master Feb 1, 2021
@villebro villebro added the v1.0.1 label Feb 2, 2021
villebro pushed a commit that referenced this pull request Feb 2, 2021
* Fix presto column_type_mappings time and timestamp

* Added unit tests
villebro pushed a commit to preset-io/superset that referenced this pull request Feb 2, 2021
* Fix presto column_type_mappings time and timestamp

* Added unit tests
@mistercrunch mistercrunch added 🍒 1.0.1 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XS v1.0.1 🍒 1.0.1 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants