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

[bugfix] temporal columns with expression fail #4890

Merged
merged 2 commits into from
Apr 27, 2018

Conversation

mistercrunch
Copy link
Member

error msg: "local variable 'literal' referenced before assignment"

Error occurs [only] when using temporal column defined as a SQL
expression.

Also noticed that examples were using granularity instead of using
granularity_sqla as they should. Fixed that here.

error msg: "local variable 'literal' referenced before assignment"

Error occurs [only] when using temporal column defined as a SQL
expression.

Also noticed that examples were using `granularity` instead of using
`granularity_sqla` as they should. Fixed that here.
def test_get_timestamp_expression(self):
tbl = self.get_table_by_name('birth_names')
ds_col = tbl.get_column('ds')
sqla_literal = ds_col.get_timestamp_expression(None)
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a test thats passing a value into get_timestamp_expression() to make sure we are returning the proper literal_col

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is the test will fail depending on the database it's working on. I guess I can figure out which engine it's on (postgres/mysql) and do the proper assertion depending on that

Copy link
Contributor

Choose a reason for hiding this comment

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

literal = expr.format(col=expr)
if grain:
literal = grain.function
literal = expr.format(col=expr)
Copy link
Contributor

@xrmx xrmx Apr 26, 2018

Choose a reason for hiding this comment

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

Isn't this line always overriding the one before? the one before should be expr = grain.function or there should be an else branch somewhere

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think this should be

literal = literal.format(col=expr)

Copy link
Member

Choose a reason for hiding this comment

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

See #4892

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I think we're both wrong on this one :( , I'm going to clean this up a bit more and write many tests covering the whole function.

@codecov-io
Copy link

codecov-io commented Apr 26, 2018

Codecov Report

Merging #4890 into master will increase coverage by 0.16%.
The diff coverage is 88.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4890      +/-   ##
==========================================
+ Coverage   76.97%   77.13%   +0.16%     
==========================================
  Files          44       44              
  Lines        8537     8542       +5     
==========================================
+ Hits         6571     6589      +18     
+ Misses       1966     1953      -13
Impacted Files Coverage Δ
superset/data/__init__.py 100% <ø> (ø) ⬆️
superset/connectors/base/models.py 90.74% <100%> (+0.23%) ⬆️
superset/connectors/sqla/models.py 76.32% <84.61%> (+2.09%) ⬆️
superset/db_engine_specs.py 52.69% <0%> (+0.53%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fa3da8c...3ac0ba5. Read the comment docs.

@mistercrunch
Copy link
Member Author

superseeds #4892

@mistercrunch mistercrunch merged commit 3f48c00 into apache:master Apr 27, 2018
@mistercrunch mistercrunch deleted the fix_literals branch April 27, 2018 04:13
michellethomas pushed a commit to michellethomas/panoramix that referenced this pull request May 24, 2018
* [bugfix] temporal columns with expression fail

error msg: "local variable 'literal' referenced before assignment"

Error occurs [only] when using temporal column defined as a SQL
expression.

Also noticed that examples were using `granularity` instead of using
`granularity_sqla` as they should. Fixed that here.

* Add tests
timifasubaa pushed a commit to timifasubaa/incubator-superset that referenced this pull request May 31, 2018
* [bugfix] temporal columns with expression fail

error msg: "local variable 'literal' referenced before assignment"

Error occurs [only] when using temporal column defined as a SQL
expression.

Also noticed that examples were using `granularity` instead of using
`granularity_sqla` as they should. Fixed that here.

* Add tests
wenchma pushed a commit to wenchma/incubator-superset that referenced this pull request Nov 16, 2018
* [bugfix] temporal columns with expression fail

error msg: "local variable 'literal' referenced before assignment"

Error occurs [only] when using temporal column defined as a SQL
expression.

Also noticed that examples were using `granularity` instead of using
`granularity_sqla` as they should. Fixed that here.

* Add tests
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.25.0 labels Feb 27, 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 🚢 0.25.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants