-
Notifications
You must be signed in to change notification settings - Fork 0
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
Upgrade to plk 0.14.6 + add UNION support #56
Conversation
Verified the transpiled test queries for each of the dialects. For reference, commands for the table creation: Redshift
Spark
Trino
|
import org.jline.reader.Highlighter | ||
import org.jline.reader.LineReader | ||
import org.jline.utils.AttributedString | ||
import org.jline.utils.AttributedStringBuilder | ||
import org.jline.utils.AttributedStyle | ||
import org.partiql.parser.antlr.PartiQLParser | ||
import org.partiql.parser.antlr.PartiQLTokens | ||
import org.partiql.parser.thirdparty.antlr.v4.runtime.BaseErrorListener |
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.
Changes in this file are due to upgrading to PLK 0.14.6, which internalized the ANTLR dependency. ANTLR runtime dependencies are available under org.partiql.parser.thirdparty.antlr.v4.runtime
rather than org.antlr.v4.runtime
.
@@ -1,23 +1,23 @@ | |||
--#[between-00] | |||
-- between(decimal, int32, int32) | |||
SELECT `T_DECIMALS`.`da` AS `da` FROM `default`.`T_DECIMALS` AS `T_DECIMALS` WHERE `T_DECIMALS`.`da` BETWEEN -1 AND 1; |
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.
Each dialect had some failing BETWEEN
tests following the upgrade to 0.14.6. These were unrelated to the UNION
changes.
@@ -89,6 +89,13 @@ abstract class SqlDialect : AstBaseVisitor<SqlBlock, SqlBlock>() { | |||
t = t concat ")" | |||
t | |||
} | |||
node is Expr.BagOp -> { |
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.
Copy over a change from the PLK PR partiql/partiql-lang-kotlin#1506 since Scribe uses its own-defined SqlDialect
.
@@ -279,7 +328,7 @@ public open class RexConverter( | |||
val newRexConverter = RexConverter(transform, Locals(relProject.input.type.schema)) | |||
val type = constructor.type as? StructType ?: return null | |||
if (type.constraints.contains(TupleConstraint.Open(false)) | |||
.not() || type.constraints.contains(TupleConstraint.Ordered).not() |
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 too sure why the previous un-planning (plan -> AST) for SELECT VALUE to SQL select required the tuple to be ordered. Was giving some issues with the plan with the Rel
set ops since they were unordered.
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.
SELECT VALUE requires orderedness because SQL tuples are ordered. That is, SELECT VALUE is only equivalent to SQL SELECT if the constructor is an ordered tuple.
SQL UNION/INTERSECT/EXCEPT should preserve the ordereness, as schema is known.
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 see. Thanks for the context. I added back the ordered tuple check in b543453
(#56).
@@ -279,7 +328,7 @@ public open class RexConverter( | |||
val newRexConverter = RexConverter(transform, Locals(relProject.input.type.schema)) | |||
val type = constructor.type as? StructType ?: return null | |||
if (type.constraints.contains(TupleConstraint.Open(false)) | |||
.not() || type.constraints.contains(TupleConstraint.Ordered).not() |
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.
SELECT VALUE requires orderedness because SQL tuples are ordered. That is, SELECT VALUE is only equivalent to SQL SELECT if the constructor is an ordered tuple.
SQL UNION/INTERSECT/EXCEPT should preserve the ordereness, as schema is known.
Issue #, if available:
UNION
in transpilation #55Description of changes:
BETWEEN
operator and ANTLR dependency internalizingBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.