@@ -1865,7 +1865,7 @@ public TableSchema getTableSchema(String table) {
18651865 */
18661866 public TableSchema getTableSchema (String table , String database ) {
18671867 final String sql = "DESCRIBE TABLE " + table + " FORMAT " + ClickHouseFormat .TSKV .name ();
1868- return getTableSchemaImpl (sql , table , null , database );
1868+ return getTableSchemaImpl (sql , table , null , database , null );
18691869 }
18701870
18711871 /**
@@ -1874,16 +1874,22 @@ public TableSchema getTableSchema(String table, String database) {
18741874 * @return table schema for the query
18751875 */
18761876 public TableSchema getTableSchemaFromQuery (String sql ) {
1877+ return getTableSchemaFromQuery (sql , null );
1878+ }
1879+
1880+ public TableSchema getTableSchemaFromQuery (String sql , Map <String , Object > params ) {
18771881 final String describeQuery = "DESC (" + sql + ") FORMAT " + ClickHouseFormat .TSKV .name ();
1878- return getTableSchemaImpl (describeQuery , null , sql , getDefaultDatabase ());
1882+ return getTableSchemaImpl (describeQuery , null , sql , getDefaultDatabase (), params );
18791883 }
18801884
1881- private TableSchema getTableSchemaImpl (String describeQuery , String name , String originalQuery , String database ) {
1885+ private TableSchema getTableSchemaImpl (
1886+ String describeQuery , String name , String originalQuery , String database , Map <String , Object > queryParams ) {
18821887 int operationTimeout = getOperationTimeout ();
18831888
18841889 QuerySettings settings = new QuerySettings ().setDatabase (database );
1885- try (QueryResponse response = operationTimeout == 0 ? query (describeQuery , settings ).get () :
1886- query (describeQuery , settings ).get (getOperationTimeout (), TimeUnit .SECONDS )) {
1890+ try (QueryResponse response = operationTimeout == 0
1891+ ? query (describeQuery , queryParams , settings ).get ()
1892+ : query (describeQuery , queryParams , settings ).get (getOperationTimeout (), TimeUnit .SECONDS )) {
18871893 return TableSchemaParser .readTSKV (response .getInputStream (), name , originalQuery , database );
18881894 } catch (TimeoutException e ) {
18891895 throw new ClientException ("Operation has likely timed out after " + getOperationTimeout () + " seconds." , e );
0 commit comments