From ebfcab721bfb67be5508828455b06ec8670da220 Mon Sep 17 00:00:00 2001 From: Akash Kulkarni <113392464+akashkulk@users.noreply.github.com> Date: Thu, 31 Aug 2023 16:01:35 -0700 Subject: [PATCH] Add escape quoting to selecting max (pk_field) query (#30059) --- .../io/airbyte/integrations/source/mysql/MySqlQueryUtils.java | 4 ++-- .../integration_tests/sources/utils/TestConstants.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/airbyte-integrations/connectors/source-mysql/src/main/java/io/airbyte/integrations/source/mysql/MySqlQueryUtils.java b/airbyte-integrations/connectors/source-mysql/src/main/java/io/airbyte/integrations/source/mysql/MySqlQueryUtils.java index 913202608868..f487b7605bad 100644 --- a/airbyte-integrations/connectors/source-mysql/src/main/java/io/airbyte/integrations/source/mysql/MySqlQueryUtils.java +++ b/airbyte-integrations/connectors/source-mysql/src/main/java/io/airbyte/integrations/source/mysql/MySqlQueryUtils.java @@ -5,6 +5,7 @@ package io.airbyte.integrations.source.mysql; import static io.airbyte.integrations.source.relationaldb.RelationalDbQueryUtils.getFullyQualifiedTableNameWithQuoting; +import static io.airbyte.integrations.source.relationaldb.RelationalDbQueryUtils.getIdentifierWithQuoting; import com.fasterxml.jackson.databind.JsonNode; import com.google.common.base.Preconditions; @@ -85,7 +86,7 @@ public static String getMaxPkValueForStream(final JdbcDatabase database, final String fullTableName = getFullyQualifiedTableNameWithQuoting(namespace, name, quoteString); final String maxPkQuery = String.format(MAX_PK_VALUE_QUERY, - pkFieldName, + getIdentifierWithQuoting(pkFieldName, quoteString), MAX_PK_COL, fullTableName); LOGGER.info("Querying for max pk value: {}", maxPkQuery); @@ -134,7 +135,6 @@ private static List getTableEstimate(final JdbcDatabase database, fina // Construct the table estimate query. final String tableEstimateQuery = String.format(TABLE_ESTIMATE_QUERY, TABLE_SIZE_BYTES_COL, AVG_ROW_LENGTH, namespace, name); - LOGGER.info("table estimate query: {}", tableEstimateQuery); final List jsonNodes = database.bufferedResultSetQuery(conn -> conn.createStatement().executeQuery(tableEstimateQuery), resultSet -> JdbcUtils.getDefaultSourceOperations().rowToJson(resultSet)); Preconditions.checkState(jsonNodes.size() == 1); diff --git a/airbyte-integrations/connectors/source-mysql/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/utils/TestConstants.java b/airbyte-integrations/connectors/source-mysql/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/utils/TestConstants.java index b88948c180fb..669e7e9144d0 100644 --- a/airbyte-integrations/connectors/source-mysql/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/utils/TestConstants.java +++ b/airbyte-integrations/connectors/source-mysql/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/utils/TestConstants.java @@ -6,6 +6,6 @@ public class TestConstants { - public static final int INITIAL_CDC_WAITING_SECONDS = 5; + public static final int INITIAL_CDC_WAITING_SECONDS = 10; }