Thanks for the reply @Danny and @Amir, let me see if I can get the SQLs generated without set the breakpoint. I am building a data service, and want to show the real SQLs executed.
Thanks! Amir Gajst <amir.ga...@sisense.com> 于2020年2月12日周三 下午2:53写道: > Set a breakpoint at *JdbcToEnumerableConverter.generateSql(SqlDialect > dialect)* > > Best > Amir > > > On Wed, Feb 12, 2020 at 7:35 AM Danny Chan <yuzhao....@gmail.com> wrote: > > > You can set a debug break point in the RelToSqlConverter I think. > > > > Best, > > Danny Chan > > 在 2020年2月11日 +0800 AM3:51,Yang Liu <whilg...@gmail.com>,写道: > > > Hi there, recently I am studying Apache Calcite, by now I can use > explain > > > plan for via JDBC to view the logical plan, and I am wondering how can > I > > > view the physical sql in the plan execution? Since there may be bugs in > > the > > > physical sql generation so I need to make sure the correctness. > > > > > > 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() > > > } > > > > > > result is > > > > > > EnumerableCalc(expr#0..3=[{inputs}], proj#0..2=[{exprs}]) > > > EnumerableHashJoin(condition=[=($0, $3)], joinType=[inner]) > > > JdbcToEnumerableConverter > > > JdbcTableScan(table=[[perm, user_table]]) > > > JdbcToEnumerableConverter > > > JdbcProject(id=[$0]) > > > JdbcTableScan(table=[[insight_user, user_tab]]) > > > > > -- > > > > [image: Sisense] > < > https://www.sisense.com/?source=xink&utm_source=xink&utm_medium=email&utm_campaign=emailsignature2018 > > > *Amir Gajst* > Software Engineer > +972-54-4766239 > amir.gajst > [image: Instagram] <https://www.instagram.com/sisense/> [image: > LinkedIn] > <https://www.linkedin.com/company/sisense> [image: Facebook] > <https://www.facebook.com/Sisense> [image: Twitter] > <https://twitter.com/Sisense> > <https://t.xink.io/Tracking/Index/0NgBAPDBAADdv0QA0> Read more about > Sisense Q4 2019 Release >> > <https://t.xink.io/Tracking/Index/0NgBAPDBAADdv0QA0> >