@@ -1731,36 +1731,53 @@ public CompletableFuture<QueryResponse> query(String sqlQuery, Map<String, Objec
17311731
17321732 return runAsyncOperation (responseSupplier , settings .getAllSettings ());
17331733 }
1734+ public CompletableFuture <QueryResponse > query (String sqlQuery , Map <String , Object > queryParams ) {
1735+ return query (sqlQuery , queryParams , null );
1736+ }
17341737
17351738 /**
17361739 * <p>Queries data in one of descriptive format and creates a reader out of the response stream.</p>
17371740 * <p>Format is selected internally so is ignored when passed in settings. If query contains format
17381741 * statement then it may cause incompatibility error.</p>
17391742 *
1740- * @param sqlQuery
1741- * @return
1743+ * @param sqlQuery - SQL statement
1744+ * @return - a promise to a result
17421745 */
17431746 public CompletableFuture <Records > queryRecords (String sqlQuery ) {
1744- return queryRecords (sqlQuery , null );
1747+ return queryRecords (sqlQuery , null , null );
17451748 }
17461749
17471750 /**
17481751 * <p>Queries data in one of descriptive format and creates a reader out of the response stream.</p>
17491752 * <p>Format is selected internally so is ignored when passed in settings. If query contains format
17501753 * statement then it may cause incompatibility error.</p>
17511754 *
1752- * @param sqlQuery
1753- * @param settings
1754- * @return
1755+ * @param sqlQuery - SQL statement
1756+ * @param settings - operation settings
1757+ * @return - a promise to a result
17551758 */
17561759 public CompletableFuture <Records > queryRecords (String sqlQuery , QuerySettings settings ) {
1760+ return queryRecords (sqlQuery , null , settings );
1761+ }
1762+
1763+ /**
1764+ * <p>Queries data in one of descriptive format and creates a reader out of the response stream.</p>
1765+ * <p>Format is selected internally so is ignored when passed in settings. If query contains format
1766+ * statement then it may cause incompatibility error.</p>
1767+ * See {@link #query(String, Map, QuerySettings)} for parametrized queries.
1768+ * @param sqlQuery - SQL statement
1769+ * @param params - sql parameters
1770+ * @param settings - operation settings
1771+ * @return - a promise to a result
1772+ */
1773+ public CompletableFuture <Records > queryRecords (String sqlQuery , Map <String , Object > params , QuerySettings settings ) {
17571774 if (settings == null ) {
17581775 settings = new QuerySettings ();
17591776 }
17601777 settings .setFormat (ClickHouseFormat .RowBinaryWithNamesAndTypes );
17611778 settings .waitEndOfQuery (true ); // we rely on the summery
17621779
1763- return query (sqlQuery , settings ).thenApply (response -> {
1780+ return query (sqlQuery , params , settings ).thenApply (response -> {
17641781 try {
17651782
17661783 return new Records (response , newBinaryFormatReader (response ));
@@ -1770,19 +1787,30 @@ public CompletableFuture<Records> queryRecords(String sqlQuery, QuerySettings se
17701787 });
17711788 }
17721789
1790+ public CompletableFuture <Records > queryRecords (String sqlQuery , Map <String , Object > params ) {
1791+ return queryRecords (sqlQuery , params , null );
1792+ }
1793+
17731794 /**
17741795 * <p>Queries data in descriptive format and reads result to a collection.</p>
17751796 * <p>Use this method for queries that would return only a few records only because client
17761797 * will read whole dataset and convert it into a list of GenericRecord</p>
1777- * @param sqlQuery - SQL query
1798+ *
1799+ * See {@link #query(String, Map, QuerySettings)} for parametrized queries.
1800+ * @param sqlQuery - SQL statement
1801+ * @param params - query parameters
1802+ * @param settings - operation settings
17781803 * @return - complete list of records
17791804 */
1780- public List <GenericRecord > queryAll (String sqlQuery , QuerySettings settings ) {
1805+ public List <GenericRecord > queryAll (String sqlQuery , Map <String , Object > params , QuerySettings settings ) {
1806+ if (settings == null ) {
1807+ settings = new QuerySettings ();
1808+ }
17811809 try {
17821810 int operationTimeout = getOperationTimeout ();
17831811 settings .setFormat (ClickHouseFormat .RowBinaryWithNamesAndTypes )
17841812 .waitEndOfQuery (true );
1785- try (QueryResponse response = operationTimeout == 0 ? query (sqlQuery , settings ).get () :
1813+ try (QueryResponse response = operationTimeout == 0 ? query (sqlQuery , params , settings ).get () :
17861814 query (sqlQuery , settings ).get (operationTimeout , TimeUnit .MILLISECONDS )) {
17871815 List <GenericRecord > records = new ArrayList <>();
17881816 if (response .getResultRows () > 0 ) {
@@ -1791,7 +1819,7 @@ public List<GenericRecord> queryAll(String sqlQuery, QuerySettings settings) {
17911819
17921820 Map <String , Object > record ;
17931821 while (reader .readRecord ((record = new LinkedHashMap <>()))) {
1794- records .add (new MapBackedRecord (record , reader .getSchema ()));
1822+ records .add (new MapBackedRecord (record , reader .getConvertions (), reader . getSchema ()));
17951823 }
17961824 }
17971825 return records ;
@@ -1803,8 +1831,16 @@ public List<GenericRecord> queryAll(String sqlQuery, QuerySettings settings) {
18031831 }
18041832 }
18051833
1834+ public List <GenericRecord > queryAll (String sqlQuery , QuerySettings settings ) {
1835+ return queryAll (sqlQuery , null , settings );
1836+ }
1837+
1838+ public List <GenericRecord > queryAll (String sqlQuery , Map <String , Object > params ) {
1839+ return queryAll (sqlQuery , params , null );
1840+ }
1841+
18061842 public List <GenericRecord > queryAll (String sqlQuery ) {
1807- return queryAll (sqlQuery , new QuerySettings () );
1843+ return queryAll (sqlQuery , null , ( QuerySettings ) null );
18081844 }
18091845
18101846 public <T > List <T > queryAll (String sqlQuery , Class <T > clazz , TableSchema schema ) {
0 commit comments