-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[CALCITE-2980] Implement the FORMAT clause of the CAST operator #3677
[CALCITE-2980] Implement the FORMAT clause of the CAST operator #3677
Conversation
core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
Outdated
Show resolved
Hide resolved
3070c02
to
3277903
Compare
9122b9f
to
a8e4f57
Compare
core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java
Show resolved
Hide resolved
a8e4f57
to
3269a70
Compare
Quality Gate passedIssues Measures |
core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks great to me, should we mention in the commit message that this is specifically for BigQuery? Add BigQuery's FORMAT clause to CAST operator
or something along those lines
3269a70
to
418ade5
Compare
418ade5
to
2dadcd1
Compare
return RexImpTable.optimize2(operand, | ||
Expressions.call(BuiltInMethod.UNIX_TIME_TO_STRING.method, | ||
operand)); | ||
return RexImpTable.optimize2(operand, Expressions.isConstantNull(format) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you evaluate this before the switch
? then you can just check the variable in each case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly, we could only move the RexImpTable.optimize2()
call outside the switch, but the specific method called to evaluate the CAST depends on the from and to cast data types, and with this change also if there is a FORMAT
present. So the number of lines would still look the same, but we could move out one level of nesting with the optimize calls and return statements outside the switch case.
Does that seem like a better pattern?
core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java
Show resolved
Hide resolved
'FMMONTH FMMonth FMmonth'); | ||
EXPR$0 | ||
AUGUST August august | ||
!ok | ||
|
||
select cast(date'2010-09-19' as string FORMAT | ||
select cast(date'2010-09-19' as varchar FORMAT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for going through these im sure that took a bit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to have the working tests enabled, and the disabled ones gives a status on whats yet to be supported and need to be addressed in followup JIRAs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good thanks for addressing all the comments, maybe we can see if @julianhyde has any suggestions otherwise merge soon?
c4c6a55
to
c2f6806
Compare
c2f6806
to
dbf33c0
Compare
Quality Gate passedIssues Measures |
No description provided.