@@ -1866,7 +1866,7 @@ public TableSchema getTableSchema(String table) {
18661866 */
18671867 public TableSchema getTableSchema (String table , String database ) {
18681868 final String sql = "DESCRIBE TABLE " + table + " FORMAT " + ClickHouseFormat .TSKV .name ();
1869- return getTableSchemaImpl (sql , table , null , database );
1869+ return getTableSchemaImpl (sql , table , null , database , null );
18701870 }
18711871
18721872 /**
@@ -1875,16 +1875,22 @@ public TableSchema getTableSchema(String table, String database) {
18751875 * @return table schema for the query
18761876 */
18771877 public TableSchema getTableSchemaFromQuery (String sql ) {
1878+ return getTableSchemaFromQuery (sql , null );
1879+ }
1880+
1881+ public TableSchema getTableSchemaFromQuery (String sql , Map <String , Object > params ) {
18781882 final String describeQuery = "DESC (" + sql + ") FORMAT " + ClickHouseFormat .TSKV .name ();
1879- return getTableSchemaImpl (describeQuery , null , sql , getDefaultDatabase ());
1883+ return getTableSchemaImpl (describeQuery , null , sql , getDefaultDatabase (), params );
18801884 }
18811885
1882- private TableSchema getTableSchemaImpl (String describeQuery , String name , String originalQuery , String database ) {
1886+ private TableSchema getTableSchemaImpl (
1887+ String describeQuery , String name , String originalQuery , String database , Map <String , Object > queryParams ) {
18831888 int operationTimeout = getOperationTimeout ();
18841889
18851890 QuerySettings settings = new QuerySettings ().setDatabase (database );
1886- try (QueryResponse response = operationTimeout == 0 ? query (describeQuery , settings ).get () :
1887- query (describeQuery , settings ).get (getOperationTimeout (), TimeUnit .SECONDS )) {
1891+ try (QueryResponse response = operationTimeout == 0
1892+ ? query (describeQuery , queryParams , settings ).get ()
1893+ : query (describeQuery , queryParams , settings ).get (getOperationTimeout (), TimeUnit .SECONDS )) {
18881894 return TableSchemaParser .readTSKV (response .getInputStream (), name , originalQuery , database );
18891895 } catch (TimeoutException e ) {
18901896 throw new ClientException ("Operation has likely timed out after " + getOperationTimeout () + " seconds." , e );
0 commit comments