Skip to content

[BUG] Driver throws exception when query starts with multi-line block comment #1201

@rileythomp

Description

@rileythomp

Describe the bug

When you try to execute a query that has a multi-line block comment above the query itself an exception is thrown.

To Reproduce

clj \
 -J--add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED \
 -Sdeps '{:deps {com.databricks/databricks-jdbc-thin {:mvn/version "3.1.1"}}}'
(do
  (import '[java.sql DriverManager])

  (with-open [conn (DriverManager/getConnection "<databricks-jdbc-url>")
              stmt (.createStatement conn)
              rs (.executeQuery stmt "/*
                                      multi line block comment
                                      */
                                      select 1;")]
    (when (.next rs)
      (.getInt rs 1))))
Execution error (DatabricksSQLException) at com.databricks.jdbc.api.impl.DatabricksStatement/executeQuery (DatabricksStatement.java:82).
A ResultSet was expected but not generated from query. However, query execution was successful.

Expected behavior

The query results are returned correctly:

1

Client side logs
n/a

Client Environment (please complete the following information):

  • OS: Mac
  • Java version: 23.0.2
  • Java vendor: OpenJDK
  • Driver Version: 3.1.1
  • BI Tool: Metabase
  • BI Tool version: 58.4

Additional context

I think it might be an issue with the regex comment parsing in trimCommentsAndWhitespaces

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions