You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "jerryleooo (Jira)" <ji...@apache.org> on 2020/02/07 06:49:00 UTC

[jira] [Created] (CALCITE-3778) Provide ways to view the physical SQLs sent to database

jerryleooo created CALCITE-3778:
-----------------------------------

             Summary: Provide ways to view the physical SQLs sent to database
                 Key: CALCITE-3778
                 URL: https://issues.apache.org/jira/browse/CALCITE-3778
             Project: Calcite
          Issue Type: Wish
          Components: core
            Reporter: jerryleooo


I am using Calcite JDBC, when executing a multiple join, I want to check if the queries/SQLs sent to databases are right. Currently seems there is no easy way to do this.

I have enabled 'calcite.debug=true' but it just gave me some Java code.
{code:java}
val connection = DriverManager.getConnection("jdbc:calcite:") 
val calciteConnection = connection.asInstanceOf[CalciteConnection] 
val rootSchema = calciteConnection.getRootSchema() 
val dsInsightUser = JdbcSchema.dataSource("jdbc:mysql://localhost:13306/insight?useSSL=false&serverTimezone=UTC", "com.mysql.jdbc.Driver", "insight_admin","xxxxxx") 
val dsPerm = JdbcSchema.dataSource("jdbc:mysql://localhost:13307/permission?useSSL=false&serverTimezone=UTC", "com.mysql.jdbc.Driver", "perm_admin", "xxxxxx") 
rootSchema.add("insight_user", JdbcSchema.create(rootSchema, "insight_user", dsInsightUser, null, null)) 
rootSchema.add("perm", JdbcSchema.create(rootSchema, "perm", dsPerm, null, null)) val stmt = connection.createStatement() 
val rs = stmt.executeQuery("""explain plan for select "perm"."user_table".* from "perm"."user_table" join "insight_user"."user_tab" on "perm"."user_table"."id"="insight_user"."user_tab"."id" """) 
val metaData = rs.getMetaData() 
while(rs.next()) { 
    for(i <- 1 to metaData.getColumnCount) printf("%s ", rs.getObject(i)) 
    println() 
}
{code}
Tried post the same question on Stackoverflow and mail list but got few replies, so tried here, forgive my taking the liberty.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)