Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bgaidioz committed May 28, 2024
1 parent 29395e1 commit 74ee7db
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ trait MySQLPackageTest extends CompilerTestContext with CredentialsTestContext w
| CAST(3.14 AS DOUBLE) AS doublecol,
| CAST(1200000000 AS DECIMAL) AS decimalcol,
| '120' AS stringcol,
| CAST('12:23:34' AS TIME) AS timecol,
| CAST('12:23:34.123' AS TIME) AS timecol,
| CAST('2020-01-01' AS DATE) AS datecol,
| CAST('2020-01-01 12:23:34' AS DATETIME) AS timestampcol,
| CAST('2020-01-01 12:23:34.123' AS DATETIME) AS timestampcol,
| 1 = 0 AS boolcol,
| convert('Olala!' using utf8) AS binarycol$ttt, type collection(
| record(
Expand Down Expand Up @@ -65,9 +65,9 @@ trait MySQLPackageTest extends CompilerTestContext with CredentialsTestContext w
| doublecol: 3.14,
| decimalcol: Decimal.From(1200000000),
| stringcol: "120",
| timecol: Time.Build(12, 23, seconds=34),
| timecol: Time.Build(12, 23, seconds=34, milliseconds=123),
| datecol: Date.Build(2020, 1, 1),
| timestampcol: Timestamp.Build(2020, 1, 1, 12, 23, seconds=34),
| timestampcol: Timestamp.Build(2020, 1, 1, 12, 23, seconds=34, milliseconds=123),
| boolcol: false,
| binarycol: Binary.FromString("Olala!")
|}]""".stripMargin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ trait PostgreSQLPackageTest extends CompilerTestContext with CredentialsTestCont
| CAST('3.14' AS DOUBLE PRECISION) AS doublecol,
| CAST('12000000' AS DECIMAL) AS decimalcol,
| CAST('120' AS VARCHAR) AS stringcol,
| CAST('12:23:34.99' AS TIME) AS timecol,
| CAST('12:23:34.123' AS TIME) AS timecol,
| CAST('2020-01-01' AS DATE) AS datecol,
| CAST('2020-01-01 12:23:34.99' AS TIMESTAMP) AS timestampcol,
| CAST('2020-01-01 12:23:34.123' AS TIMESTAMP) AS timestampcol,
| CAST('false' AS BOOL) AS boolcol,
| decode('T2xhbGEh', 'base64') as binarycol$ttt, type collection(
| record(
Expand Down Expand Up @@ -65,9 +65,9 @@ trait PostgreSQLPackageTest extends CompilerTestContext with CredentialsTestCont
| doublecol: 3.14,
| decimalcol: Decimal.From(12000000),
| stringcol: "120",
| timecol: Time.Build(12, 23, seconds=34, milliseconds=990),
| timecol: Time.Build(12, 23, seconds=34, milliseconds=123),
| datecol: Date.Build(2020, 1, 1),
| timestampcol: Timestamp.Build(2020, 1, 1, 12, 23, seconds=34, milliseconds=990),
| timestampcol: Timestamp.Build(2020, 1, 1, 12, 23, seconds=34, milliseconds=123),
| boolcol: false,
| binarycol: Binary.FromString("Olala!")
|}]""".stripMargin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ trait SnowflakePackageTest extends CompilerTestContext with CredentialsTestConte
| CAST('3.14' AS FLOAT8) AS "doublecol",
| CAST('12000000' AS DECIMAL) AS "decimalcol",
| CAST('120' AS VARCHAR) AS "stringcol",
| CAST('12:23:34' AS TIME) AS "timecol",
| CAST('12:23:34.123' AS TIME) AS "timecol",
| CAST('2020-01-01' AS DATE) AS "datecol",
| CAST('2020-01-01 12:23:34' AS DATETIME) AS "timestampcol",
| CAST('2020-01-01 12:23:34.123' AS DATETIME) AS "timestampcol",
| 1 = 0 AS "boolcol",
| to_binary('tralala', 'utf-8') AS "binarycol" $ttt, type collection(
| record(
Expand Down Expand Up @@ -67,9 +67,9 @@ trait SnowflakePackageTest extends CompilerTestContext with CredentialsTestConte
| doublecol: 3.14,
| decimalcol: Decimal.From(12000000),
| stringcol: "120",
| timecol: Time.Build(12, 23, seconds=34),
| timecol: Time.Build(12, 23, seconds=34, milliseconds=123),
| datecol: Date.Build(2020, 1, 1),
| timestampcol: Timestamp.Build(2020, 1, 1, 12, 23, seconds=34),
| timestampcol: Timestamp.Build(2020, 1, 1, 12, 23, seconds=34, milliseconds=123),
| boolcol: false,
| binarycol: String.Encode("tralala", "utf-8")
|}]""".stripMargin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ trait SqlServerPackageTest extends CompilerTestContext with CredentialsTestConte
| CAST('3.14' AS DOUBLE PRECISION) AS doublecol,
| CAST('12000000' AS DECIMAL) AS decimalcol,
| CAST('120' AS VARCHAR) AS stringcol,
| CAST('12:23:34' AS TIME) AS timecol,
| CAST('12:23:34.123' AS TIME) AS timecol,
| CAST('2020-01-01' AS DATE) AS datecol,
| CAST('2020-01-01 12:23:34' AS DATETIME) AS timestampcol,
| CAST('2020-01-01 12:23:34.123' AS DATETIME) AS timestampcol,
| CAST('Olala!' AS VARBINARY(MAX)) AS binarycol $ttt)""".stripMargin) { it =>
it should typeAs("""collection(
| record(
Expand All @@ -64,9 +64,9 @@ trait SqlServerPackageTest extends CompilerTestContext with CredentialsTestConte
| doublecol: 3.14,
| decimalcol: Decimal.From(12000000),
| stringcol: "120",
| timecol: Time.Build(12, 23, seconds=34),
| timecol: Time.Build(12, 23, seconds=34, milliseconds=123),
| datecol: Date.Build(2020, 1, 1),
| timestampcol: Timestamp.Build(2020, 1, 1, 12, 23, seconds=34),
| timestampcol: Timestamp.Build(2020, 1, 1, 12, 23, seconds=34, milliseconds=123),
| binarycol: Binary.FromString("Olala!")
|}]""".stripMargin)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ class NamedParametersPreparedStatement(conn: Connection, parsedTree: ParseProgra
case RawString(v) => setString(paramName, v)
case RawDecimal(v) => setBigDecimal(paramName, v)
case RawDate(v) => setDate(paramName, java.sql.Date.valueOf(v))
case RawTime(v) => setTime(paramName, new java.sql.Time(v.toNanoOfDay/1000000))
case RawTime(v) => setTime(paramName, new java.sql.Time(v.toNanoOfDay / 1000000))
case RawTimestamp(v) => setTimestamp(paramName, java.sql.Timestamp.valueOf(v))
case RawInterval(years, months, weeks, days, hours, minutes, seconds, millis) => ???
case RawBinary(v) => setBytes(paramName, v)
Expand Down Expand Up @@ -561,7 +561,7 @@ class NamedParametersPreparedStatement(conn: Connection, parsedTree: ParseProgra
case java.sql.Types.FLOAT => RawFloat(rs.getFloat(1))
case java.sql.Types.DOUBLE => RawDouble(rs.getDouble(1))
case java.sql.Types.DATE => RawDate(rs.getDate(1).toLocalDate)
case java.sql.Types.TIME => RawTime(LocalTime.ofNanoOfDay(rs.getTime(1, zonedCalendar).getTime*1000000))
case java.sql.Types.TIME => RawTime(LocalTime.ofNanoOfDay(rs.getTime(1, zonedCalendar).getTime * 1000000))
case java.sql.Types.TIMESTAMP => RawTimestamp(rs.getTimestamp(1, zonedCalendar).toLocalDateTime)
case java.sql.Types.BOOLEAN => RawBool(rs.getBoolean(1))
case java.sql.Types.VARCHAR => RawString(rs.getString(1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class TypedResultSetJsonWriter(os: OutputStream) {
val date = v.getDate(i).toLocalDate
gen.writeString(dateFormatter.format(date))
case _: RawTimeType =>
val time = LocalTime.ofNanoOfDay(v.getTime(i, zonedCalendar).getTime*1000000)
val time = LocalTime.ofNanoOfDay(v.getTime(i, zonedCalendar).getTime * 1000000)
val formatted = timeFormatter.format(time)
gen.writeString(formatted)
case _: RawTimestampType =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1066,9 +1066,8 @@ class TestSqlCompilerServiceAirports
assert(baos.toString() == """[{"t":"12:13:14.567"}]""")
}

test(
"""-- @default t TIME WITHOUT TIME ZONE '12:13:14.567'
|SELECT :t AS t""".stripMargin) { t =>
test("""-- @default t TIME WITHOUT TIME ZONE '12:13:14.567'
|SELECT :t AS t""".stripMargin) { t =>
val ValidateResponse(errors) = compilerService.validate(t.q, asJson())
assert(errors.isEmpty)
val GetProgramDescriptionSuccess(description) = compilerService.getProgramDescription(t.q, asJson())
Expand Down

0 comments on commit 74ee7db

Please sign in to comment.