Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Mihai Budiu <[email protected]>
  • Loading branch information
mihaibudiu committed Sep 14, 2023
1 parent b6679d0 commit 34f52c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ public static SqlNode toSql(RexLiteral literal) {
castNonNull(literal.getValueAs(TimestampString.class)),
literal.getType().getPrecision(), POS);
case BINARY:
return SqlLiteral.createBinaryString(requireNonNull(literal.getValueAs(byte[].class)), POS);
return SqlLiteral.createBinaryString(castNonNull(literal.getValueAs(byte[].class)), POS);
case ANY:
case NULL:
switch (typeName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,14 @@ private static String toSql(RelNode root, SqlDialect dialect,
* Test for <a href="https://issues.apache.org/jira/browse/CALCITE-5988">[CALCITE-5988]</a>
* SqlImplementor.toSql cannot emit VARBINARY literals.
*/
@Test void testBinary() {
@Test void testBinaryLiteral() {
String query = "SELECT x'ABCD'";
String expected = "SELECT X'ABCD'";
// We use Mysql here because using the default Calcite dialect
// the expected string is a bit too verbose:
// "SELECT *\nFROM (VALUES (X'ABCD')) AS \"t\" (\"EXPR$0\")"
sql(query).withMysql().ok(expected);
sql("SELECT cast(null as binary)").withMysql().ok("SELECT NULL");
}

@Test void testGroupByBooleanLiteral() {
Expand Down

0 comments on commit 34f52c5

Please sign in to comment.