|
51 | 51 | import com.facebook.presto.sql.planner.Symbol; |
52 | 52 | import com.facebook.presto.sql.planner.TypeProvider; |
53 | 53 | import com.facebook.presto.sql.relational.FunctionResolution; |
| 54 | +import com.facebook.presto.sql.tree.EnumLiteral; |
54 | 55 | import com.facebook.presto.sql.tree.Expression; |
55 | 56 | import com.facebook.presto.sql.tree.ExpressionRewriter; |
56 | 57 | import com.facebook.presto.sql.tree.ExpressionTreeRewriter; |
@@ -899,6 +900,20 @@ public void testReservedWithDoubleQuotes() |
899 | 900 | assertOptimizedEquals("\"time\"", "\"time\""); |
900 | 901 | } |
901 | 902 |
|
| 903 | + @Test |
| 904 | + public void testEnumLiteralFormattingWithTypeAndValue() |
| 905 | + { |
| 906 | + java.util.function.BiFunction<String, Object, EnumLiteral> createEnumLiteral = (type, value) -> new EnumLiteral(Optional.empty(), type, value); |
| 907 | + assertEquals(ExpressionFormatter.formatExpression(createEnumLiteral.apply("color", "RED"), Optional.empty()), "color: RED"); |
| 908 | + assertEquals(ExpressionFormatter.formatExpression(createEnumLiteral.apply("level", 1), Optional.empty()), "level: 1"); |
| 909 | + assertEquals(ExpressionFormatter.formatExpression(createEnumLiteral.apply("StatusType", "Active"), Optional.empty()), "StatusType: Active"); |
| 910 | + assertEquals(ExpressionFormatter.formatExpression(createEnumLiteral.apply("priority", "HIGH PRIORITY"), Optional.empty()), "priority: HIGH PRIORITY"); |
| 911 | + assertEquals(ExpressionFormatter.formatExpression(createEnumLiteral.apply("lang", "枚举"), Optional.empty()), "lang: 枚举"); |
| 912 | + assertEquals(ExpressionFormatter.formatExpression(createEnumLiteral.apply("special", "DOLLAR$"), Optional.empty()), "special: DOLLAR$"); |
| 913 | + assertEquals(ExpressionFormatter.formatExpression(createEnumLiteral.apply("enum_type", "VALUE_1"), Optional.empty()), "enum_type: VALUE_1"); |
| 914 | + assertEquals(ExpressionFormatter.formatExpression(createEnumLiteral.apply("flag", true), Optional.empty()), "flag: true"); |
| 915 | + } |
| 916 | + |
902 | 917 | @Test |
903 | 918 | public void testSearchCase() |
904 | 919 | { |
|
0 commit comments