[ 
https://issues.apache.org/jira/browse/CALCITE-6293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17888697#comment-17888697
 ] 

Caican Cai edited comment on CALCITE-6293 at 10/11/24 3:26 PM:
---------------------------------------------------------------

[~julianhyde][~asolimando]
Hello, I encountered difficulties in supporting the or operator. I found that 
the structure of the code cannot support this operator.

I have located the following code, whereClause is a List<String>. I have reason 
to guess that each element in the List is a filter condition, but this seems to 
only apply to and. When I get the List<String>, the current code will 
automatically generate a similar form such as where stringlist.get(0) and 
stringlist.get(1). It seems that or is not supported. I don't know how to use 
List<String> to represent or, or should I refactor this part of the code so 
that it can determine whether to generate the filter condition of the OR 
operator or the and operator based on some flags of my List<String>.

{code:java}
    return implementor.result(physType,
        Blocks.toBlock(
            Expressions.call(table.getExpression(ArrowTable.class),
                ArrowMethod.ARROW_QUERY.method, implementor.getRootExpression(),
                arrowImplementor.selectFields != null
                    ? Expressions.call(
                        BuiltInMethod.IMMUTABLE_INT_LIST_COPY_OF.method,
                        Expressions.constant(
                            Ints.toArray(arrowImplementor.selectFields)))
                    : Expressions.call(
                        BuiltInMethod.IMMUTABLE_INT_LIST_IDENTITY.method,
                        Expressions.constant(fieldCount)),
                Expressions.constant(arrowImplementor.whereClause))));
{code}



was (Author: JIRAUSER302115):
[~julianhyde][~asolimando]
Hello, I encountered difficulties in supporting the or operator. I found that 
the structure of the code cannot support this operator.

I have located the following code, whereClause is a List<String>. I have reason 
to guess that each element in the List is a filter condition, but this seems to 
only apply to and. When I get the List<String>, the current code will 
automatically generate similar forms such as where stringlist.get(0) and 
stringlist.get(1). It seems that or is not supported. I don't know how to use 
List<String> to represent or, or should I refactor this part of the code so 
that it can determine whether to generate or or and filter conditions based on 
some flags of my List<String>.

{code:java}
    return implementor.result(physType,
        Blocks.toBlock(
            Expressions.call(table.getExpression(ArrowTable.class),
                ArrowMethod.ARROW_QUERY.method, implementor.getRootExpression(),
                arrowImplementor.selectFields != null
                    ? Expressions.call(
                        BuiltInMethod.IMMUTABLE_INT_LIST_COPY_OF.method,
                        Expressions.constant(
                            Ints.toArray(arrowImplementor.selectFields)))
                    : Expressions.call(
                        BuiltInMethod.IMMUTABLE_INT_LIST_IDENTITY.method,
                        Expressions.constant(fieldCount)),
                Expressions.constant(arrowImplementor.whereClause))));
{code}


> Support OR condition in Arrow adapter
> -------------------------------------
>
>                 Key: CALCITE-6293
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6293
>             Project: Calcite
>          Issue Type: Sub-task
>          Components: arrow-adapter
>            Reporter: hongyu guo
>            Assignee: Tim Grein
>            Priority: Major
>
> For example
> {code:java}
> String sql = "select \"intField\", \"stringField\"\n"
>     + "from arrowdata\n"
>     + "where \"intField\"=12 or \"stringField\"='12'"; {code}
> will throw an exception:
> {code:java}
> java.lang.AssertionError: cannot translate OR(=($0, 12), =($1, '12'))
>       at 
> org.apache.calcite.adapter.arrow.ArrowTranslator.translateMatch(ArrowTranslator.java:70)
>       at 
> org.apache.calcite.adapter.arrow.ArrowFilter.<init>(ArrowFilter.java:43)
>       at 
> org.apache.calcite.adapter.arrow.ArrowRules$ArrowFilterRule.convert(ArrowRules.java:97)
>       at 
> org.apache.calcite.adapter.arrow.ArrowRules$ArrowFilterRule.onMatch(ArrowRules.java:87)
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to