Probably (and hopefully) not much difference. We know that not everyone 
has/wants a JDBC connection, and not every query is most naturally expressed in 
SQL, so we tried to make all of the combinations possible. Some of the non-JDBC 
options may still create a JDBC connection under the covers, which is not 
ideal. 


> On Jun 21, 2022, at 1:07 PM, Gavin Ray <[email protected]> wrote:
> 
> From what I've been able to tell, surface-level functionally the below work
> the same
> but I'm wondering whether there are any differences/any scenarios to prefer
> one to the other?
> 
> ======================================
> fun executeQuery(sql: String): ResultSet {
>    val planner = Frameworks.getPlanner(frameworkConfig)
>    val sqlNode = planner.parse(sql)
>    val validated = planner.validate(sqlNode)
>    val relRoot = planner.rel(validated).project()
> 
>    relRoot.cluster.planner.root = relRoot.cluster.planner.changeTraits(
>        relRoot,
>        relRoot.cluster.traitSet().replace(EnumerableConvention.INSTANCE)
>    )
>    val bestExp = relRoot.cluster.planner.findBestExp()
> 
>    val relRunner = connection.unwrap(RelRunner::class.java)
>    return relRunner.prepareStatement(bestExp).executeQuery()
> }
> 
> ======================================
> fun executeQuery(sql: String): ResultSet {
>    val stmt = CalciteSchemaService.connection.createStatement()
>    return stmt.executeQuery(sql)
> }

Reply via email to