databricks / databricks-sql-go

Golang database/sql driver for Databricks SQL.
Apache License 2.0
34 stars 38 forks source link

Named parameter support and update Thrift #155

Closed rcypher-databricks closed 10 months ago

rcypher-databricks commented 10 months ago

Updated thrift client code to latest version. Added support for named query parameters. Not yet complete. The correct sql type needs to be set in TSparkParameter struct. Need to add support for date/time and intervals.

mattdeekay commented 10 months ago

To be consistent with odbc/jdbc (which actually will not have named param support), do we have positional param support on the roadmap? I understand the server support is work in progress but i think the client side support should be very similar between two. We can introduce a switch to turn positional param on when the server is done.

Another question is: do we check server versions? I should find out the versions that named param and positional params are supported. Someone on BIX-internal must know.

We do have client-side positional param support with this change. The Go SQL spec allows users to add positional OR named parameters like this: c.ExecContext(ctx, query, args ...any)

In order for customers to use named parameters, they might do this: c.ExecContext(ctx, "SELECT :param_a, :param_b FROM sample", NamedArg{Name: "param_a", Value: "test_value_a"}, NamedArg{Name: "param_b", Value: "test_value_b"})

But the driver will receive []driver.NamedValue for both positional and named. It's up to the driver to send the correct TSparkParameter to the thrift server.