Skip to content

SQL: Improved behavior when implicitly casting strings to date/time literals.#5023

Merged
jihoonson merged 2 commits intoapache:masterfrom
gianm:sql-time-filter-string
Nov 10, 2017
Merged

SQL: Improved behavior when implicitly casting strings to date/time literals.#5023
jihoonson merged 2 commits intoapache:masterfrom
gianm:sql-time-filter-string

Conversation

@gianm
Copy link
Copy Markdown
Contributor

@gianm gianm commented Oct 31, 2017

  • Handle all flavors of ISO8601 and SQL literals.
  • Throw errors on other literals instead of silently transforming them to 0.

…iterals.

- Handle all flavors of ISO8601 and SQL literals.
- Throw errors on other literals instead of silently transforming them to 0.
@fjy fjy modified the milestones: 0.11.0, 0.11.1 Nov 1, 2017
@fjy
Copy link
Copy Markdown
Contributor

fjy commented Nov 1, 2017

👍

ImmutableList.of(
operand,
DruidExpression.fromExpression(DruidExpression.stringLiteral(dateTimeFormatString(toType))),
DruidExpression.fromExpression(DruidExpression.nullLiteral()),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this mean the dateTimeFormat parameter is always null when casting? If so, the below timeZone parameter looks not necessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It does, but the timezone is still useful, since null for the format really just means "use iso or sql format" and that may still need a time zone to interpret the value.

For example timestamp_parse('2000-01-01 00:00:00', null, 'UTC') and timestamp_parse('2000-01-01 00:00:00', null, 'America/Los_Angeles') return different values.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I mean, timezone looks not used if formatString is null (https://github.com/druid-io/druid/blob/master/processing/src/main/java/io/druid/query/expression/TimestampParseExprMacro.java#L58-L61). Maybe we need to fix TimestampParseExprMacro to use timezone for null formatString as well?

Copy link
Copy Markdown
Contributor Author

@gianm gianm Nov 8, 2017

Choose a reason for hiding this comment

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

Oh, sorry, you're right! This is a bug in TimestampParseExprMacro. I pushed another commit fixing it to this PR, and added a test.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

Copy link
Copy Markdown
Contributor

@jihoonson jihoonson left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@jihoonson jihoonson merged commit 9444da5 into apache:master Nov 10, 2017
@gianm gianm deleted the sql-time-filter-string branch September 23, 2022 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants