-
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
Add datetime literal printing for Redshift, Trino, and Spark #53
Conversation
From testing some observations:
|
* TODO: Copied from partiql-lang-kotlin's [org.partiql.value.io.PartiQLValueTextWriter]. Delete after | ||
* https://github.com/partiql/partiql-lang-kotlin/issues/1491 is resolved and released as a new PartiQL Kotlin version. |
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.
File is identical to the PartiQLValueWriter
from partiql/partiql-lang-kotlin#1492. Copied here until we release the updated PartiQLValueWriter
in a new release.
@@ -33,7 +33,6 @@ import org.partiql.ast.visitor.AstBaseVisitor | |||
import org.partiql.value.MissingValue | |||
import org.partiql.value.NullValue | |||
import org.partiql.value.PartiQLValueExperimental | |||
import org.partiql.value.io.PartiQLValueTextWriter |
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.
Have the base SqlDialect
rely on the Scribe PartiQLValueTextWriter
rather than the v0.14.5 PartiQLValueTextWriter
, which is missing the latest date, time, timestamp printing.
// Essentially the same as `SqlDialect`. For SQL time and timestamp literals, Redshift (like Postgresql) requires | ||
// specifying if the time/timestamp has a timezone in the type name. Otherwise, the offset will be ignored. | ||
// Postgresql reference -- https://www.postgresql.org/docs/16/datatype-datetime.html#DATATYPE-DATETIME-INPUT-TIME-STAMPS |
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.
Comment summarizes the changes for Redshift time and timestamp w/ offset translation. Date remains the same.
@@ -113,6 +114,15 @@ public open class SparkDialect : SqlDialect() { | |||
return tail concat list(start, end) { node.values } | |||
} | |||
|
|||
@OptIn(PartiQLValueExperimental::class) |
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.
Spark date and timestamp literals follow same behavior as PartiQL. Spark does not have a time type so error.
@@ -0,0 +1,48 @@ | |||
-- DATE |
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.
Fortunately, Trino seems to have the same parsing and evaluation behavior as PartiQL for datetime types.
Description of changes:
PartiQLValueTextWriter
from Add implementation of date, time, and timestamp values forPartiQLValueTextWriter
partiql-lang-kotlin#1492WITH TIME ZONE
/TZ
forTIME
andTIMESTAMP
s with a time zone offsetBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.