You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Hongze Zhang (JIRA)" <ji...@apache.org> on 2018/08/29 13:05:00 UTC
[jira] [Updated] (CALCITE-2485) ES adapter returns wrong result
when single projection is used
[ https://issues.apache.org/jira/browse/CALCITE-2485?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Hongze Zhang updated CALCITE-2485:
----------------------------------
Summary: ES adapter returns wrong result when single projection is used (was: ES adapter returns wrong result with single projection)
> ES adapter returns wrong result when single projection is used
> --------------------------------------------------------------
>
> Key: CALCITE-2485
> URL: https://issues.apache.org/jira/browse/CALCITE-2485
> Project: Calcite
> Issue Type: Bug
> Components: elasticsearch-adapter
> Affects Versions: 1.17.0
> Reporter: Hongze Zhang
> Assignee: Julian Hyde
> Priority: Major
>
> SQL text:
> {code:sql}
> SELECT a."city_str", b."col" FROM (SELECT cast(_MAP['city'] AS VARCHAR(20)) AS "city_str" FROM ES_SCHEMA."es_table" LIMIT 10) a CROSS JOIN (SELECT "col" FROM DRUID_SCHEMA."druid_table" LIMIT 10) b;
> {code}
> Explain plan:
> {code:java}
> EnumerableCalc(expr#0..1=[{inputs}], city_str=[$t1], field5=[$t0])
> EnumerableJoin(condition=[true], joinType=[inner])
> EnumerableInterpreter
> DruidQuery(table=[[DRUID_SCHEMA, druid_table]], intervals=[[1900-01-01T00:00:00.000Z/3000-01-01T00:00:00.000Z]], projects=[[$11]], fetch=[10])
> ElasticsearchToEnumerableConverter
> ElasticsearchProject(city_str=[CAST(ITEM($0, 'city')):VARCHAR(20) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary"])
> ElasticsearchSort(fetch=[10])
> ElasticsearchTableScan(table=[[ES_SCHEMA, es_table]])
> {code}
> Run into exception:
> {code:java}
> <init>:58, ClassCastException (java.lang)
> apply:-1, Baz$2
> toLookup_:2662, EnumerableDefaults (org.apache.calcite.linq4j)
> toLookup:2652, EnumerableDefaults (org.apache.calcite.linq4j)
> toLookup:2628, EnumerableDefaults (org.apache.calcite.linq4j)
> toLookup:705, DefaultEnumerable (org.apache.calcite.linq4j)
> enumerator:1074, EnumerableDefaults$6 (org.apache.calcite.linq4j)
> <init>:-1, Baz$4$1
> enumerator:-1, Baz$4
> iterator:33, AbstractEnumerable (org.apache.calcite.linq4j)
> createCursor:90, MetaImpl (org.apache.calcite.avatica)
> execute:184, AvaticaResultSet (org.apache.calcite.avatica)
> execute:64, CalciteResultSet (org.apache.calcite.jdbc)
> execute:43, CalciteResultSet (org.apache.calcite.jdbc)
> execute:667, AvaticaConnection$1 (org.apache.calcite.avatica)
> prepareAndExecute:566, CalciteMetaImpl (org.apache.calcite.jdbc)
> prepareAndExecuteInternal:675, AvaticaConnection (org.apache.calcite.avatica)
> executeInternal:156, AvaticaStatement (org.apache.calcite.avatica)
> execute:217, AvaticaStatement (org.apache.calcite.avatica)
> execute:823, Commands (sqlline)
> sql:733, Commands (sqlline)
> dispatch:795, SqlLine (sqlline)
> begin:668, SqlLine (sqlline)
> start:373, SqlLine (sqlline)
> main:265, SqlLine (sqlline)
> {code}
> Reason:
> # The logic of CAST function is actually to be done in method ElasticsearchEnumerators.convert(Object o, Class clazz) in Elasticsearch Adaptor;
> # Map-to-String convertion is missing in that method;
> # Because of 1 and 2, the hit map returned from ElasticsearchEnumerators.singletonGetter is directly returned to join enumerator;
> # The implementation of EnumerableJoin could perform a forcible type casting on select keys via method PhysType.generateAccessor(List<Integer> fields);
> # The casting is from raw type to derived type of RexNode, which means EnumerableJoin forces a Map-to-String casting in this case.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)