yuqi created CALCITE-2637:
-----------------------------

             Summary: Prefix minus operator failed in between and clause
                 Key: CALCITE-2637
                 URL: https://issues.apache.org/jira/browse/CALCITE-2637
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.17.0
         Environment: We can reproduce it like this 


{code:java}
public static void main(String[] args) {
                try {
                        SchemaPlus rootSchema = 
Frameworks.createRootSchema(true);

                        rootSchema.add("TABLE_RESULT", new AbstractTable() {
                                public RelDataType getRowType(final 
RelDataTypeFactory typeFactory) {
                                        RelDataTypeFactory.FieldInfoBuilder 
builder = typeFactory.builder();

                                        RelDataType t1 = 
typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.INTEGER),
 true);
                                        RelDataType t2 = 
typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.CHAR),
 true);
                                        RelDataType t3 = 
typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.INTEGER),
 true);

                                        builder.add("ID", t1);
                                        builder.add("NAME", t2);
                                        builder.add("SCORE", t3);;
                                        return builder.build();
                                }
                        });
                        final FrameworkConfig config = 
Frameworks.newConfigBuilder()
                                        .parserConfig(SqlParser.Config.DEFAULT)
                                        .defaultSchema(rootSchema)
                                        .build();
                        Planner planner = Frameworks.getPlanner(config);

                        String sql = "select id, score between - score * 5 and 
100 from table_result";


                        SqlNode parse = planner.parse(sql);
                        SqlNode validate = planner.validate(parse);

                        RelRoot root = planner.rel(validate);

                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
{code}

the above code will cause the following problem:


{code:java}
org.apache.calcite.sql.parser.SqlParseException: Encountered "- score" at line 
1, column 26.
Was expecting one of:
    "SYMMETRIC" ...
    "ASYMMETRIC" ...
    "+" ...
    "-" ...
    "-" <UNSIGNED_INTEGER_LITERAL> ...
    "-" <DECIMAL_NUMERIC_LITERAL> ...
    "-" <APPROX_NUMERIC_LITERAL> ...
    <UNSIGNED_INTEGER_LITERAL> ...
    <DECIMAL_NUMERIC_LITERAL> ...
    <APPROX_NUMERIC_LITERAL> ...
    <BINARY_STRING_LITERAL> ...
    <PREFIXED_STRING_LITERAL> ...
    <QUOTED_STRING> ...
    <UNICODE_STRING_LITERAL> ...
    "TRUE" ...
    "FALSE" ...
    "UNKNOWN" ...
    "NULL" ...
    <LBRACE_D> ...
    <LBRACE_T> ...
    <LBRACE_TS> ...
    "DATE" ...
    "TIME" ...
    "TIMESTAMP" ...
    "INTERVAL" ...
    "?" ...
    "CAST" ...
    "EXTRACT" ...
    "POSITION" ...
    "CONVERT" ...
    "TRANSLATE" ...
    "OVERLAY" ...
    "FLOOR" ...
    "CEIL" ...
    "CEILING" ...
    "SUBSTRING" ...
    "TRIM" ...
    "CLASSIFIER" ...
    "MATCH_NUMBER" ...
    "RUNNING" ...
    "PREV" ...
    "NEXT" ...
    <LBRACE_FN> ...
    "MULTISET" ...
    "ARRAY" ...
    "PERIOD" ...
    "SPECIFIC" ...
    <IDENTIFIER> ...
    <QUOTED_IDENTIFIER> ...
    <BACK_QUOTED_IDENTIFIER> ...
    <BRACKET_QUOTED_IDENTIFIER> ...
    <UNICODE_QUOTED_IDENTIFIER> ...
    "ABS" ...
    "AVG" ...
    "CARDINALITY" ...
    "CHAR_LENGTH" ...
    "CHARACTER_LENGTH" ...
    "COALESCE" ...
    "COLLECT" ...
    "COVAR_POP" ...
    "COVAR_SAMP" ...
{code}

            Reporter: yuqi
            Assignee: Julian Hyde
             Fix For: 1.18.0






--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to