Skip to content

Commit

Permalink
Merge branch 'main' into partiql-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
RCHowell authored Jul 12, 2023
2 parents 6c60fad + 44e8a8d commit 62a4dab
Show file tree
Hide file tree
Showing 37 changed files with 4,899 additions and 971 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ Thank you to all who have contributed!
values
- Adds `org.partiql.ast` package and usage documentation
- Adds `org.partiql.parser` package and usage documentation
- Adds PartiQL's Timestamp Data Model.
- Adds support for Timestamp constructor call in Parser.


### Changed

Expand All @@ -47,6 +50,7 @@ Thank you to all who have contributed!
### Contributors
Thank you to all who have contributed!
- @howero
- @yliuuuu
- @<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

0 comments on commit 62a4dab

Please sign in to comment.