Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1436,8 +1436,8 @@ nonTrivialPrimitiveType
| INTERVAL
(fromYearMonth=(YEAR | MONTH) (TO to=MONTH)? |
fromDayTime=(DAY | HOUR | MINUTE | SECOND) (TO to=(HOUR | MINUTE | SECOND))?)?
| TIMESTAMP (WITHOUT TIME ZONE)?
| TIME (LEFT_PAREN precision=integerValue RIGHT_PAREN)? (WITHOUT TIME ZONE)?
| TIMESTAMP (withLocalTimeZone | withoutTimeZone)?
| TIME (LEFT_PAREN precision=integerValue RIGHT_PAREN)? (withoutTimeZone)?
| GEOGRAPHY LEFT_PAREN (srid=integerValue | any=ANY) RIGHT_PAREN
| GEOMETRY LEFT_PAREN (srid=integerValue | any=ANY) RIGHT_PAREN
;
Expand All @@ -1457,6 +1457,14 @@ trivialPrimitiveType
| VARIANT
;

withLocalTimeZone
: WITH LOCAL TIME ZONE
;

withoutTimeZone
: WITHOUT TIME ZONE
;

primitiveType
: nonTrivialPrimitiveType
| trivialPrimitiveType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,12 @@ class DataTypeAstBuilder extends SqlBaseParserBaseVisitor[AnyRef] with DataTypeE
} else {
CalendarIntervalType
}
case TIMESTAMP if currentCtx.withLocalTimeZone() != null =>
TimestampType
case TIMESTAMP if currentCtx.withoutTimeZone() != null =>
TimestampNTZType
case TIMESTAMP =>
if (currentCtx.WITHOUT() == null) {
SqlApiConf.get.timestampType
} else TimestampNTZType
SqlApiConf.get.timestampType
case TIME =>
val precision = if (currentCtx.precision == null) {
TimeType.DEFAULT_PRECISION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class DataTypeParserSuite extends SparkFunSuite with SQLHelper {
checkDataType("TIME(6)", TimeType(6))
checkDataType("TIME(6) WITHOUT TIME ZONE", TimeType(6))
checkDataType("timestamp", TimestampType)
checkDataType("TIMESTAMP WITH LOCAL TIME ZONE", TimestampType)
checkDataType("TIMESTAMP WITHOUT TIME ZONE", TimestampNTZType)
checkDataType("timestamp_ntz", TimestampNTZType)
checkDataType("timestamp_ltz", TimestampType)
Expand Down Expand Up @@ -158,9 +159,12 @@ class DataTypeParserSuite extends SparkFunSuite with SQLHelper {
test("Set default timestamp type") {
withSQLConf(SQLConf.TIMESTAMP_TYPE.key -> TimestampTypes.TIMESTAMP_NTZ.toString) {
assert(parse("timestamp") === TimestampNTZType)
assert(parse("timestamp with local time zone") === TimestampType)
assert(parse("timestamp without time zone") === TimestampNTZType)
}
withSQLConf(SQLConf.TIMESTAMP_TYPE.key -> TimestampTypes.TIMESTAMP_LTZ.toString) {
assert(parse("timestamp") === TimestampType)
assert(parse("timestamp with local time zone") === TimestampType)
assert(parse("timestamp without time zone") === TimestampNTZType)
}
}
Expand Down