[
https://issues.apache.org/jira/browse/CALCITE-1031?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15124795#comment-15124795
]
zhen wang commented on CALCITE-1031:
------------------------------------
This is a hack which works ( all case pass )
https://github.com/apache/calcite/compare/master...zinking:1031-scan-twice2?expand=1
Revisiting: from the face of it, the sql plan is executed twice causing table
scanned twice. firstly when result set is needed and secondly after the result
set is generated and to actually retrieve the result set content.
In my understanding, The intention of this lies in `RemoteMeta` design. where
for the `RemoteMeta` the first execution is delegated to server side where
result set is wrapped but not retrieved. and the second execute is to retrieve
the content from the wrapped result set. Certainly, the `RemoteMeta` doesn’t
deal with `TableScan` anyways. so this is good for RemoteMeta.
but for the ‘Local’ Meta CalciteMetaImpl, both the two executions falls back to
the same call, that is wrapping the result set for client use. thus making the
Table scanned twice. CalciteMetaImpl certainly does not require the execution
to be delegated to remote, so in this case the first execution can be safely
skipped.
The fix is a bit hacky though, currently no way provided to distinct these
metas.
[~julianhyde] let me know what do you think. thanks.
> In prepared statement, CsvScannableTable.scan is called twice
> -------------------------------------------------------------
>
> Key: CALCITE-1031
> URL: https://issues.apache.org/jira/browse/CALCITE-1031
> Project: Calcite
> Issue Type: Bug
> Components: avatica
> Affects Versions: 1.5.0
> Environment: jdk 1.8.0_20 linux mint 17.3
> Reporter: Anıl Chalil
> Assignee: Julian Hyde
> Priority: Minor
> Attachments: threads_report.txt, threads_report2.txt
>
>
> Hi,
> I just noticed something when i am playing with examples.
> {code}
> Class.forName("org.apache.calcite.jdbc.Driver")
> val properties: Properties = new Properties()
> properties.setProperty("caseSensitive","true")
> val connection = DriverManager.getConnection("jdbc:calcite:", properties)
> val calciteConnection=connection.unwrap(classOf[CalciteConnection])
> val schema= (new
> CsvSchemaFactory()).create(calciteConnection.getRootSchema,null,Map[String,AnyRef]("directory"
> -> "src/main/resources/csv","flavor" -> "scannable").asJava)
> calciteConnection.getRootSchema.add("TEST",schema)
> val statement2=calciteConnection.prepareStatement("select \"tarih\" from
> \"TEST\".\"timeseries\" where \"sensor\" = ?")
> statement2.setString(1,"sensor38")
> val resultSet1=statement2.executeQuery()
> while(resultSet1.next())
> println(resultSet1.getString("tarih"))
> {code}
> My example like above. But when i call executeQuery i noticed that
> CsvScannableTable.scan called twice and enumerator iterating on values. When
> i inspected stacktraces i found that one of the call come from
> AvaticaConnection.java:463 and the other one is AvaticaConnection:489 .
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)