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

Timestamp Data Model #1121

Merged
merged 16 commits into from
Jul 11, 2023
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Thank you to all who have contributed!
### Added
- Adds `org.partiql.value` (experimental) package for reading/writing PartiQL
values
- Adds PartiQL's Timestamp Data Model.
- Adds support for Timestamp constructor call in Parser.

### Changed

Expand All @@ -45,6 +47,7 @@ Thank you to all who have contributed!
### Contributors
Thank you to all who have contributed!
- @howero
- @yliuuuu
yliuuuu marked this conversation as resolved.
Show resolved Hide resolved
- @<your-username>

## [0.12.0] - 2023-06-14
Expand Down
19 changes: 16 additions & 3 deletions partiql-ast/src/main/pig/partiql.ion
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ may then be further optimized by selecting better implementations of each operat
// Constructors for DateTime types
(date year::int month::int day::int)
(lit_time value::time_value)
(timestamp value::timestamp_value)

// Bag operators
(bag_op op::bag_op_type quantifier::set_quantifier operands::(* expr 2))
Expand Down Expand Up @@ -178,6 +179,19 @@ may then be further optimized by selecting better implementations of each operat
// Time
(product time_value hour::int minute::int second::int nano::int precision::int with_time_zone::bool tz_minutes::(? int))

// Timestamp
(product timestamp_value year::int month::int day::int hour::int minute::int second::ion timezone::(? timezone) precision::(? int) )

(sum timezone
// Unknown time zone -00:00
(unknown_timezone)
// UTC offset ex: -01:30 -> tz_hour = -1, tz_minutes = -30, total offset minutes = -90
// tz_hour is in [-23, 23], timezone minutes is in [-59,59]
// we only need total offset minutes to model this property
(utc_offset offset_minutes::int)
// TODO: Timezone ID not support yet. Ex: US/Pacific
)

// A "step" within a path expression; that is the components of the expression following the root.
(sum path_step
// `someRoot[<expr>]`, or `someRoot.someField` which is equivalent to `someRoot['someField']`.
Expand Down Expand Up @@ -535,9 +549,6 @@ may then be further optimized by selecting better implementations of each operat
// `NUMERIC[(<int> [, int])]`. Elements are precision then scale.
(numeric_type precision::(? int) scale::(? int))

// `TIMESTAMP`
(timestamp_type)

// `CHAR(<int>)`
(character_type length::(? int))

Expand All @@ -557,6 +568,8 @@ may then be further optimized by selecting better implementations of each operat
// Note: This logic is implemented in SqlParser.
(time_type precision::(? int))
(time_with_time_zone_type precision::(? int))
(timestamp_type precision::(? int))
(timestamp_with_time_zone_type precision::(? int))

(struct_type)
(tuple_type)
Expand Down
13 changes: 13 additions & 0 deletions partiql-lang/src/main/kotlin/org/partiql/lang/errors/ErrorCode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ enum class ErrorCode(
"invalid precision used for TIME type"
),

// TODO: We should combine this with the above
PARSE_INVALID_PRECISION_FOR_TIMESTAMP(
ErrorCategory.PARSER,
LOC_TOKEN,
"invalid precision used for TIMESTAMP type"
),

PARSE_INVALID_DATE_STRING(
ErrorCategory.PARSER,
LOC_TOKEN,
Expand All @@ -155,6 +162,12 @@ enum class ErrorCode(
"expected time string to be of the format HH:MM:SS[.dddd...][+|-HH:MM]"
),

PARSE_INVALID_DATETIME_STRING(
ErrorCategory.PARSER,
LOC_TOKEN,
"Invalid timestamp string"
),

PARSE_INVALID_TRIM_SPEC(
ErrorCategory.PARSER,
LOC_TOKEN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ internal class EvaluatingCompiler(

is PartiqlAst.Expr.GraphMatch -> compileGraphMatch(expr, metas)
is PartiqlAst.Expr.CallWindow -> TODO("Evaluating Compiler doesn't support window function")
is PartiqlAst.Expr.Timestamp -> TODO()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ internal class PhysicalPlanCompilerImpl(
is PartiqlPhysical.Expr.BindingsToValues -> compileBindingsToValues(expr)
is PartiqlPhysical.Expr.Pivot -> compilePivot(expr, metas)
is PartiqlPhysical.Expr.GraphMatch -> TODO("Physical compilation of GraphMatch expression")
is PartiqlPhysical.Expr.Timestamp -> TODO()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class SubqueryCoercionVisitorTransform : VisitorTransformBase() {
is PartiqlAst.Expr.CanLosslessCast -> n
is PartiqlAst.Expr.NullIf -> n
is PartiqlAst.Expr.Coalesce -> n
is PartiqlAst.Expr.Timestamp -> TODO()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ class ASTPrettyPrinter {
)
is PartiqlAst.Expr.GraphMatch -> TODO("Unsupported GraphMatch AST node")
is PartiqlAst.Expr.CallWindow -> TODO("PrettyPrinter doesn't support Window Function yet.")
is PartiqlAst.Expr.Timestamp -> TODO()
}

private fun toRecursionTreeList(nodes: List<PartiqlAst.Expr>, attrOfParent: String? = null): List<RecursionTree> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ class QueryPrettyPrinter {
is PartiqlAst.Expr.CallWindow -> TODO()
is PartiqlAst.Expr.GraphMatch -> TODO()
is PartiqlAst.Expr.SessionAttribute -> writeSessionAttribute(node, sb)
is PartiqlAst.Expr.Timestamp -> TODO()
}
}

Expand Down
Loading
Loading