@@ -1865,7 +1865,7 @@ public TableSchema getTableSchema(String table) {
1865
1865
*/
1866
1866
public TableSchema getTableSchema (String table , String database ) {
1867
1867
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 );
1869
1869
}
1870
1870
1871
1871
/**
@@ -1874,16 +1874,22 @@ public TableSchema getTableSchema(String table, String database) {
1874
1874
* @return table schema for the query
1875
1875
*/
1876
1876
public TableSchema getTableSchemaFromQuery (String sql ) {
1877
+ return getTableSchemaFromQuery (sql , null );
1878
+ }
1879
+
1880
+ public TableSchema getTableSchemaFromQuery (String sql , Map <String , Object > params ) {
1877
1881
final String describeQuery = "DESC (" + sql + ") FORMAT " + ClickHouseFormat .TSKV .name ();
1878
- return getTableSchemaImpl (describeQuery , null , sql , getDefaultDatabase ());
1882
+ return getTableSchemaImpl (describeQuery , null , sql , getDefaultDatabase (), params );
1879
1883
}
1880
1884
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 ) {
1882
1887
int operationTimeout = getOperationTimeout ();
1883
1888
1884
1889
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 )) {
1887
1893
return TableSchemaParser .readTSKV (response .getInputStream (), name , originalQuery , database );
1888
1894
} catch (TimeoutException e ) {
1889
1895
throw new ClientException ("Operation has likely timed out after " + getOperationTimeout () + " seconds." , e );
0 commit comments