You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/11/28 12:24:47 UTC

[camel] branch master updated (34513fe -> 98c7873)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 34513fe  Deprecate camel connectors related in catalog
     new 87b5015  CAMEL-12930 - Ability to execute DML statements in Google Bigquery component, thanks to Roman Lusnikov for the patch
     new a8ce423  CAMEL-12930 - Fixed CS and sb starter
     new 98c7873  CAMEL-12930 - Regen

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../main/docs/google-bigquery-sql-component.adoc   | 151 +++++++++++++++++++
 .../google/bigquery/GoogleBigQueryConstants.java   |   1 +
 .../bigquery/sql/GoogleBigQuerySQLComponent.java   |  82 +++++++++++
 .../sql/GoogleBigQuerySQLConfiguration.java        |  77 ++++++++++
 .../bigquery/sql/GoogleBigQuerySQLEndpoint.java    |  74 ++++++++++
 .../bigquery/sql/GoogleBigQuerySQLProducer.java    | 160 +++++++++++++++++++++
 .../component/google/bigquery/sql/SqlHelper.java   | 101 +++++++++++++
 .../org/apache/camel/component/google-bigquery-sql |   9 +-
 .../integration/sql/SqlQueryFromResourceTest.java  |  85 +++++++++++
 .../bigquery/integration/sql/SqlQueryTest.java     |  85 +++++++++++
 .../unit/sql/GoogleBigQuerySQLComponentTest.java   |  49 +++++++
 .../sql/GoogleBigQuerySQLProducerBaseTest.java     |  59 ++++++++
 .../GoogleBigQuerySQLProducerWithParamersTest.java |  91 ++++++++++++
 .../GoogleBigQuerySQLProducerWithPatternTest.java  |  69 +++++++++
 .../google/bigquery/unit/sql/SqlHelperTest.java    |  98 +++++++++++++
 .../src/test/resources/sql/delete.sql              |   1 +
 .../src/test/resources/sql/insert.sql              |   2 +
 components/readme.adoc                             |   5 +-
 docs/user-manual/en/SUMMARY.md                     |   1 +
 ...oogleBigQuerySQLComponentAutoConfiguration.java | 130 +++++++++++++++++
 .../GoogleBigQuerySQLComponentConfiguration.java   |  93 ++++++++++++
 .../src/main/resources/META-INF/spring.factories   |   4 +-
 22 files changed, 1420 insertions(+), 7 deletions(-)
 create mode 100644 components/camel-google-bigquery/src/main/docs/google-bigquery-sql-component.adoc
 create mode 100644 components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLComponent.java
 create mode 100644 components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLConfiguration.java
 create mode 100644 components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLEndpoint.java
 create mode 100644 components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLProducer.java
 create mode 100644 components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/SqlHelper.java
 copy platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/resources/META-INF/spring.factories => components/camel-google-bigquery/src/main/resources/META-INF/services/org/apache/camel/component/google-bigquery-sql (78%)
 create mode 100644 components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQueryFromResourceTest.java
 create mode 100644 components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQueryTest.java
 create mode 100644 components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLComponentTest.java
 create mode 100644 components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerBaseTest.java
 create mode 100644 components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithParamersTest.java
 create mode 100644 components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithPatternTest.java
 create mode 100644 components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/SqlHelperTest.java
 create mode 100644 components/camel-google-bigquery/src/test/resources/sql/delete.sql
 create mode 100644 components/camel-google-bigquery/src/test/resources/sql/insert.sql
 create mode 100644 platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentAutoConfiguration.java
 create mode 100644 platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentConfiguration.java


[camel] 02/03: CAMEL-12930 - Fixed CS and sb starter

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit a8ce42321164f2f6e471a9a190012320cbbf9f87
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Nov 28 12:32:51 2018 +0100

    CAMEL-12930 - Fixed CS and sb starter
---
 .../bigquery/sql/GoogleBigQuerySQLComponent.java   |   3 +-
 .../sql/GoogleBigQuerySQLConfiguration.java        |   9 +-
 .../bigquery/sql/GoogleBigQuerySQLEndpoint.java    |  28 ++---
 .../bigquery/sql/GoogleBigQuerySQLProducer.java    |  93 +++++++--------
 .../component/google/bigquery/sql/SqlHelper.java   |  31 +++--
 .../unit/sql/GoogleBigQuerySQLComponentTest.java   |   7 +-
 .../sql/GoogleBigQuerySQLProducerBaseTest.java     |  19 ++-
 .../GoogleBigQuerySQLProducerWithParamersTest.java |   6 +-
 .../GoogleBigQuerySQLProducerWithPatternTest.java  |   4 +-
 .../google/bigquery/unit/sql/SqlHelperTest.java    |  45 +++----
 ...oogleBigQuerySQLComponentAutoConfiguration.java | 130 +++++++++++++++++++++
 .../GoogleBigQuerySQLComponentConfiguration.java   |  93 +++++++++++++++
 .../src/main/resources/META-INF/spring.factories   |   4 +-
 13 files changed, 349 insertions(+), 123 deletions(-)

diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLComponent.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLComponent.java
index fcbcf66..a0b2363 100644
--- a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLComponent.java
+++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLComponent.java
@@ -73,7 +73,8 @@ public class GoogleBigQuerySQLComponent extends DefaultComponent {
     }
 
     /**
-     * ConnectionFactory to obtain connection to Bigquery Service. If non provided the default one will be used
+     * ConnectionFactory to obtain connection to Bigquery Service. If non
+     * provided the default one will be used
      */
     public void setConnectionFactory(GoogleBigQueryConnectionFactory connectionFactory) {
         this.connectionFactory = connectionFactory;
diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLConfiguration.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLConfiguration.java
index 25ed0dff..5e766a0 100644
--- a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLConfiguration.java
+++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLConfiguration.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -46,7 +46,8 @@ public class GoogleBigQuerySQLConfiguration {
     }
 
     /**
-     * ConnectionFactory to obtain connection to Bigquery Service. If non provided the default will be used.
+     * ConnectionFactory to obtain connection to Bigquery Service. If non
+     * provided the default will be used.
      */
     public GoogleBigQueryConnectionFactory getConnectionFactory() {
         return connectionFactory;
diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLEndpoint.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLEndpoint.java
index fee9e96..4138faa 100644
--- a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLEndpoint.java
+++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLEndpoint.java
@@ -25,23 +25,18 @@ import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 
 /**
- * Google BigQuery data warehouse for analytics.
- * 
- * BigQuery Endpoint Definition
- * Represents a table within a BigQuery dataset
- * Contains configuration details for a single table and the utility methods (such as check, create) to ease operations
- * URI Parameters:
- * * Logger ID - To ensure that logging is unified under Route Logger, the logger ID can be passed on
- *               via an endpoint URI parameter
- * * Partitioned - to indicate that the table needs to be partitioned - every UTC day to be written into a
- *                 timestamped separate table
- *                 side effect: Australian operational day is always split between two UTC days, and, therefore, tables
- *
- * Another consideration is that exceptions are not handled within the class. They are expected to bubble up and be handled
- * by Camel.
+ * Google BigQuery data warehouse for analytics. BigQuery Endpoint Definition
+ * Represents a table within a BigQuery dataset Contains configuration details
+ * for a single table and the utility methods (such as check, create) to ease
+ * operations URI Parameters: * Logger ID - To ensure that logging is unified
+ * under Route Logger, the logger ID can be passed on via an endpoint URI
+ * parameter * Partitioned - to indicate that the table needs to be partitioned
+ * - every UTC day to be written into a timestamped separate table side effect:
+ * Australian operational day is always split between two UTC days, and,
+ * therefore, tables Another consideration is that exceptions are not handled
+ * within the class. They are expected to bubble up and be handled by Camel.
  */
-@UriEndpoint(firstVersion = "2.23.0", scheme = "google-bigquery-sql", title = "Google BigQuery Standard SQL", syntax = "google-bigquery-sql:query",
-    label = "cloud,messaging", producerOnly = true)
+@UriEndpoint(firstVersion = "2.23.0", scheme = "google-bigquery-sql", title = "Google BigQuery Standard SQL", syntax = "google-bigquery-sql:query", label = "cloud,messaging", producerOnly = true)
 public class GoogleBigQuerySQLEndpoint extends DefaultEndpoint {
 
     @UriParam
@@ -76,5 +71,4 @@ public class GoogleBigQuerySQLEndpoint extends DefaultEndpoint {
         return (GoogleBigQuerySQLComponent)super.getComponent();
     }
 
-
 }
diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLProducer.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLProducer.java
index e9ce93d..eb13666 100644
--- a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLProducer.java
+++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLProducer.java
@@ -1,29 +1,40 @@
 /**
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements.  See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.  You may obtain a
- * copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.camel.component.google.bigquery.sql;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import com.google.api.services.bigquery.Bigquery;
-import com.google.api.services.bigquery.model.*;
+import com.google.api.services.bigquery.model.QueryParameter;
+import com.google.api.services.bigquery.model.QueryParameterType;
+import com.google.api.services.bigquery.model.QueryParameterValue;
+import com.google.api.services.bigquery.model.QueryRequest;
+import com.google.api.services.bigquery.model.QueryResponse;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.RuntimeExchangeException;
 import org.apache.camel.component.google.bigquery.GoogleBigQueryConstants;
 import org.apache.camel.impl.DefaultProducer;
 
-import java.util.*;
-
 /**
  * Generic BigQuery Producer
  */
@@ -34,27 +45,24 @@ public class GoogleBigQuerySQLProducer extends DefaultProducer {
     private String query;
     private Set<String> queryParameterNames;
 
-    public GoogleBigQuerySQLProducer(Bigquery bigquery, GoogleBigQuerySQLEndpoint endpoint,
-                                     GoogleBigQuerySQLConfiguration configuration) {
+    public GoogleBigQuerySQLProducer(Bigquery bigquery, GoogleBigQuerySQLEndpoint endpoint, GoogleBigQuerySQLConfiguration configuration) {
         super(endpoint);
         this.bigquery = bigquery;
         this.configuration = configuration;
     }
 
     /**
-     * Process the exchange
-     *
-     * The incoming exchange can be a grouped exchange in which case all the exchanges will be combined.
-     *
-     * The incoming can be
+     * Process the exchange The incoming exchange can be a grouped exchange in
+     * which case all the exchanges will be combined. The incoming can be
      * <ul>
-     *     <li>A map where all map keys will map to field records. One map object maps to one bigquery row</li>
-     *     <li>A list of maps. Each entry in the list will map to one bigquery row</li>
+     * <li>A map where all map keys will map to field records. One map object
+     * maps to one bigquery row</li>
+     * <li>A list of maps. Each entry in the list will map to one bigquery
+     * row</li>
      * </ul>
-     * The incoming message is expected to be a List of Maps
-     * The assumptions:
-     * - All incoming records go into the same table
-     * - Incoming records sorted by the timestamp
+     * The incoming message is expected to be a List of Maps The assumptions: -
+     * All incoming records go into the same table - Incoming records sorted by
+     * the timestamp
      */
     @Override
     public void process(Exchange exchange) throws Exception {
@@ -67,19 +75,14 @@ public class GoogleBigQuerySQLProducer extends DefaultProducer {
     }
 
     private Long executeSQL(String translatedQuery, Map<String, Object> queryParameters) throws Exception {
-        QueryRequest apiQueryRequest = new QueryRequest()
-                .setQuery(translatedQuery)
-                .setUseLegacySql(false);
+        QueryRequest apiQueryRequest = new QueryRequest().setQuery(translatedQuery).setUseLegacySql(false);
 
-        Bigquery.Jobs.Query apiQuery = bigquery
-                .jobs()
-                .query(configuration.getProjectId(), apiQueryRequest);
+        Bigquery.Jobs.Query apiQuery = bigquery.jobs().query(configuration.getProjectId(), apiQueryRequest);
 
         setQueryParameters(queryParameters, apiQueryRequest);
 
         if (log.isTraceEnabled()) {
-            log.trace("Sending query to bigquery standard sql: {}",
-                    translatedQuery);
+            log.trace("Sending query to bigquery standard sql: {}", translatedQuery);
         }
 
         QueryResponse apiResponse = apiQuery.execute();
@@ -89,15 +92,15 @@ public class GoogleBigQuerySQLProducer extends DefaultProducer {
         }
 
         if (log.isTraceEnabled()) {
-            log.trace("Result of query {} is {}",
-                    translatedQuery, apiResponse.toPrettyString());
+            log.trace("Result of query {} is {}", translatedQuery, apiResponse.toPrettyString());
         }
         return apiResponse.getNumDmlAffectedRows();
     }
 
     private Map<String, Object> extractParameters(Exchange exchange) {
-        if (queryParameterNames == null || queryParameterNames.size() == 0)
+        if (queryParameterNames == null || queryParameterNames.size() == 0) {
             return null;
+        }
 
         Message message = exchange.getMessage();
 
@@ -124,15 +127,14 @@ public class GoogleBigQuerySQLProducer extends DefaultProducer {
     }
 
     private void setQueryParameters(Map<String, Object> params, QueryRequest apiQueryRequest) {
-        if (params == null)
+        if (params == null) {
             return;
+        }
 
         List<QueryParameter> list = new ArrayList<>();
         params.forEach((key, value) -> {
             QueryParameter param = new QueryParameter();
-            param.setName(key)
-                    .setParameterType(new QueryParameterType().setType("STRING"))
-                    .setParameterValue(new QueryParameterValue().setValue(value.toString()));
+            param.setName(key).setParameterType(new QueryParameterType().setType("STRING")).setParameterValue(new QueryParameterValue().setValue(value.toString()));
             list.add(param);
         });
         apiQueryRequest.setQueryParameters(list);
@@ -145,15 +147,14 @@ public class GoogleBigQuerySQLProducer extends DefaultProducer {
 
     @Override
     public GoogleBigQuerySQLEndpoint getEndpoint() {
-        return (GoogleBigQuerySQLEndpoint) super.getEndpoint();
+        return (GoogleBigQuerySQLEndpoint)super.getEndpoint();
     }
 
     @Override
     protected void doStart() throws Exception {
         super.doStart();
         String placeholder = ":#"; // TODO
-        query = SqlHelper
-                .resolveQuery(getEndpoint().getCamelContext(), configuration.getQuery(), placeholder);
+        query = SqlHelper.resolveQuery(getEndpoint().getCamelContext(), configuration.getQuery(), placeholder);
         queryParameterNames = SqlHelper.extractParameterNames(query);
     }
 }
diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/SqlHelper.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/SqlHelper.java
index eb41856..9ecd2e2 100644
--- a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/SqlHelper.java
+++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/SqlHelper.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,9 +16,6 @@
  */
 package org.apache.camel.component.google.bigquery.sql;
 
-import org.apache.camel.*;
-import org.apache.camel.util.ResourceHelper;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.HashSet;
@@ -26,6 +23,13 @@ import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.NoTypeConversionAvailableException;
+import org.apache.camel.RuntimeExchangeException;
+import org.apache.camel.util.ResourceHelper;
+
 public final class SqlHelper {
 
     private static Pattern pattern = Pattern.compile("\\$\\{(\\w+)}");
@@ -35,13 +39,13 @@ public final class SqlHelper {
     }
 
     /**
-     * Resolve the query by loading the query from the classpath or file resource if needed.
+     * Resolve the query by loading the query from the classpath or file
+     * resource if needed.
      */
     public static String resolveQuery(CamelContext camelContext, String query, String placeholder) throws NoTypeConversionAvailableException, IOException {
         String answer = query;
         if (ResourceHelper.hasScheme(query)) {
-            InputStream is = ResourceHelper
-                    .resolveMandatoryResourceAsInputStream(camelContext, query);
+            InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext, query);
             answer = camelContext.getTypeConverter().mandatoryConvertTo(String.class, is);
             if (placeholder != null) {
                 answer = answer.replaceAll(placeholder, "@");
@@ -51,8 +55,9 @@ public final class SqlHelper {
     }
 
     /**
-     * Replaces pattern in query in form of "${param}" with values from message header
-     * Raises an error if param value not found in headers
+     * Replaces pattern in query in form of "${param}" with values from message
+     * header Raises an error if param value not found in headers
+     * 
      * @param exchange
      * @return Translated query text
      */
@@ -66,8 +71,9 @@ public final class SqlHelper {
             String value = message.getHeader(paramKey, String.class);
             if (value == null) {
                 value = exchange.getProperty(paramKey, String.class);
-                if (value == null)
+                if (value == null) {
                     throw new RuntimeExchangeException("SQL pattern with name '" + paramKey + "' not found in the message headers", exchange);
+                }
             }
 
             String replacement = Matcher.quoteReplacement(value);
@@ -79,6 +85,7 @@ public final class SqlHelper {
 
     /**
      * Extracts list of parameters in form "@name" from query text
+     * 
      * @param query
      * @return list of parameter names
      */
diff --git a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLComponentTest.java b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLComponentTest.java
index ba24d0d..5cd5d2c 100644
--- a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLComponentTest.java
+++ b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLComponentTest.java
@@ -16,17 +16,14 @@
  */
 package org.apache.camel.component.google.bigquery.unit.sql;
 
-import static org.junit.Assert.assertEquals;
-
 import org.apache.camel.CamelContext;
-import org.apache.camel.component.google.bigquery.GoogleBigQueryComponent;
-import org.apache.camel.component.google.bigquery.GoogleBigQueryEndpoint;
 import org.apache.camel.component.google.bigquery.sql.GoogleBigQuerySQLComponent;
 import org.apache.camel.component.google.bigquery.sql.GoogleBigQuerySQLEndpoint;
-import org.apache.camel.component.google.bigquery.sql.SqlHelper;
 import org.junit.Test;
 import org.mockito.Mockito;
 
+import static org.junit.Assert.assertEquals;
+
 public class GoogleBigQuerySQLComponentTest {
     private CamelContext context = Mockito.mock(CamelContext.class);
 
diff --git a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerBaseTest.java b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerBaseTest.java
index 244f27c..fa28b70 100644
--- a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerBaseTest.java
+++ b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerBaseTest.java
@@ -1,3 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.camel.component.google.bigquery.unit.sql;
 
 import com.google.api.services.bigquery.Bigquery;
@@ -37,8 +53,7 @@ public class GoogleBigQuerySQLProducerBaseTest extends CamelTestSupport {
         when(bigquery.jobs()).thenReturn(mockJobs);
         when(bigquery.jobs().query(anyString(), any())).thenReturn(mockQuery);
 
-        QueryResponse mockResponse = new QueryResponse()
-                .setNumDmlAffectedRows(1L);
+        QueryResponse mockResponse = new QueryResponse().setNumDmlAffectedRows(1L);
         when(mockQuery.execute()).thenReturn(mockResponse);
     }
 }
diff --git a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithParamersTest.java b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithParamersTest.java
index 6227dfb..5eaa916 100644
--- a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithParamersTest.java
+++ b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithParamersTest.java
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.component.google.bigquery.unit.sql;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import com.google.api.services.bigquery.model.QueryRequest;
 import org.apache.camel.Exchange;
 import org.apache.camel.RuntimeExchangeException;
@@ -23,9 +26,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.verify;
 
diff --git a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithPatternTest.java b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithPatternTest.java
index 11cb050..93ac997 100644
--- a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithPatternTest.java
+++ b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithPatternTest.java
@@ -16,14 +16,14 @@
  */
 package org.apache.camel.component.google.bigquery.unit.sql;
 
+import java.util.List;
+
 import com.google.api.services.bigquery.model.QueryRequest;
 import org.apache.camel.Exchange;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
-import java.util.List;
-
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.verify;
 
diff --git a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/SqlHelperTest.java b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/SqlHelperTest.java
index de46355..1ab2b2f 100644
--- a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/SqlHelperTest.java
+++ b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/SqlHelperTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.google.bigquery.unit.sql;
 
+import java.util.Set;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
@@ -25,13 +27,23 @@ import org.junit.Ignore;
 import org.junit.Test;
 import org.mockito.Mockito;
 
-import java.util.Set;
-
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.when;
 
 public class SqlHelperTest {
+
+    String query = "INSERT INTO ${report}.test( -- TODO \n" + "  id,\n" + "  region\n" + ")\n" + "SELECT\n" + "  id,\n" + "  region\n" + "FROM\n" + "  ${import}.test\n" + "WHERE\n"
+                   + "  rec_date = @date AND id = @id\n";
+
+    String expected = "INSERT INTO report_data.test( -- TODO \n" + "  id,\n" + "  region\n" + ")\n" + "SELECT\n" + "  id,\n" + "  region\n" + "FROM\n" + "  import_data.test\n"
+                      + "WHERE\n" + "  rec_date = @date AND id = @id\n";
+
+    Exchange exchange = Mockito.mock(Exchange.class);
+    Message message = Mockito.mock(Message.class);
+    
     private CamelContext context = Mockito.mock(CamelContext.class);
 
     @Test
@@ -47,33 +59,6 @@ public class SqlHelperTest {
         assertEquals("delete from test.test_sql_table where id = @id", answer);
     }
 
-    String query = "INSERT INTO ${report}.test( -- TODO \n" +
-            "  id,\n" +
-            "  region\n" +
-            ")\n" +
-            "SELECT\n" +
-            "  id,\n" +
-            "  region\n" +
-            "FROM\n" +
-            "  ${import}.test\n" +
-            "WHERE\n" +
-            "  rec_date = @date AND id = @id\n";
-
-    String expected = "INSERT INTO report_data.test( -- TODO \n" +
-            "  id,\n" +
-            "  region\n" +
-            ")\n" +
-            "SELECT\n" +
-            "  id,\n" +
-            "  region\n" +
-            "FROM\n" +
-            "  import_data.test\n" +
-            "WHERE\n" +
-            "  rec_date = @date AND id = @id\n";
-
-    Exchange exchange = Mockito.mock(Exchange.class);
-    Message message = Mockito.mock(Message.class);
-
     @Test
     public void testTranslateQuery() {
         when(exchange.getMessage()).thenReturn(message);
diff --git a/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentAutoConfiguration.java
new file mode 100644
index 0000000..f2028bd
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentAutoConfiguration.java
@@ -0,0 +1,130 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.google.bigquery.sql.springboot;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Generated;
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.google.bigquery.sql.GoogleBigQuerySQLComponent;
+import org.apache.camel.spi.ComponentCustomizer;
+import org.apache.camel.spi.HasId;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.ComponentConfigurationProperties;
+import org.apache.camel.spring.boot.util.CamelPropertiesHelper;
+import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans;
+import org.apache.camel.spring.boot.util.GroupCondition;
+import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator;
+import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Conditional;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
+
+/**
+ * Generated by camel-package-maven-plugin - do not edit this file!
+ */
+@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
+@Configuration
+@Conditional({ConditionalOnCamelContextAndAutoConfigurationBeans.class,
+        GoogleBigQuerySQLComponentAutoConfiguration.GroupConditions.class})
+@AutoConfigureAfter(CamelAutoConfiguration.class)
+@EnableConfigurationProperties({ComponentConfigurationProperties.class,
+        GoogleBigQuerySQLComponentConfiguration.class})
+public class GoogleBigQuerySQLComponentAutoConfiguration {
+
+    private static final Logger LOGGER = LoggerFactory
+            .getLogger(GoogleBigQuerySQLComponentAutoConfiguration.class);
+    @Autowired
+    private ApplicationContext applicationContext;
+    @Autowired
+    private CamelContext camelContext;
+    @Autowired
+    private GoogleBigQuerySQLComponentConfiguration configuration;
+    @Autowired(required = false)
+    private List<ComponentCustomizer<GoogleBigQuerySQLComponent>> customizers;
+
+    static class GroupConditions extends GroupCondition {
+        public GroupConditions() {
+            super("camel.component", "camel.component.google-bigquery-sql");
+        }
+    }
+
+    @Lazy
+    @Bean(name = "google-bigquery-sql-component")
+    @ConditionalOnMissingBean(GoogleBigQuerySQLComponent.class)
+    public GoogleBigQuerySQLComponent configureGoogleBigQuerySQLComponent()
+            throws Exception {
+        GoogleBigQuerySQLComponent component = new GoogleBigQuerySQLComponent();
+        component.setCamelContext(camelContext);
+        Map<String, Object> parameters = new HashMap<>();
+        IntrospectionSupport.getProperties(configuration, parameters, null,
+                false);
+        for (Map.Entry<String, Object> entry : parameters.entrySet()) {
+            Object value = entry.getValue();
+            Class<?> paramClass = value.getClass();
+            if (paramClass.getName().endsWith("NestedConfiguration")) {
+                Class nestedClass = null;
+                try {
+                    nestedClass = (Class) paramClass.getDeclaredField(
+                            "CAMEL_NESTED_CLASS").get(null);
+                    HashMap<String, Object> nestedParameters = new HashMap<>();
+                    IntrospectionSupport.getProperties(value, nestedParameters,
+                            null, false);
+                    Object nestedProperty = nestedClass.newInstance();
+                    CamelPropertiesHelper.setCamelProperties(camelContext,
+                            nestedProperty, nestedParameters, false);
+                    entry.setValue(nestedProperty);
+                } catch (NoSuchFieldException e) {
+                }
+            }
+        }
+        CamelPropertiesHelper.setCamelProperties(camelContext, component,
+                parameters, false);
+        if (ObjectHelper.isNotEmpty(customizers)) {
+            for (ComponentCustomizer<GoogleBigQuerySQLComponent> customizer : customizers) {
+                boolean useCustomizer = (customizer instanceof HasId)
+                        ? HierarchicalPropertiesEvaluator
+                                .evaluate(
+                                        applicationContext.getEnvironment(),
+                                        "camel.component.customizer",
+                                        "camel.component.google-bigquery-sql.customizer",
+                                        ((HasId) customizer).getId())
+                        : HierarchicalPropertiesEvaluator
+                                .evaluate(applicationContext.getEnvironment(),
+                                        "camel.component.customizer",
+                                        "camel.component.google-bigquery-sql.customizer");
+                if (useCustomizer) {
+                    LOGGER.debug("Configure component {}, with customizer {}",
+                            component, customizer);
+                    customizer.customize(component);
+                }
+            }
+        }
+        return component;
+    }
+}
\ No newline at end of file
diff --git a/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentConfiguration.java
new file mode 100644
index 0000000..fc08356
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentConfiguration.java
@@ -0,0 +1,93 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.google.bigquery.sql.springboot;
+
+import javax.annotation.Generated;
+import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+/**
+ * Google BigQuery data warehouse for analytics. BigQuery Endpoint Definition
+ * Represents a table within a BigQuery dataset Contains configuration details
+ * for a single table and the utility methods (such as check, create) to ease
+ * operations URI Parameters: Logger ID - To ensure that logging is unified
+ * under Route Logger, the logger ID can be passed on via an endpoint URI
+ * parameter Partitioned - to indicate that the table needs to be partitioned -
+ * every UTC day to be written into a timestamped separate table side effect:
+ * Australian operational day is always split between two UTC days, and,
+ * therefore, tables Another consideration is that exceptions are not handled
+ * within the class. They are expected to bubble up and be handled by Camel.
+ * 
+ * Generated by camel-package-maven-plugin - do not edit this file!
+ */
+@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
+@ConfigurationProperties(prefix = "camel.component.google-bigquery-sql")
+public class GoogleBigQuerySQLComponentConfiguration
+        extends
+            ComponentConfigurationPropertiesCommon {
+
+    /**
+     * Whether to enable auto configuration of the google-bigquery-sql
+     * component. This is enabled by default.
+     */
+    private Boolean enabled;
+    /**
+     * Google Cloud Project Id
+     */
+    private String projectId;
+    /**
+     * ConnectionFactory to obtain connection to Bigquery Service. If non
+     * provided the default one will be used
+     */
+    private GoogleBigQueryConnectionFactoryNestedConfiguration connectionFactory;
+    /**
+     * Whether the component should resolve property placeholders on itself when
+     * starting. Only properties which are of String type can use property
+     * placeholders.
+     */
+    private Boolean resolvePropertyPlaceholders = true;
+
+    public String getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(String projectId) {
+        this.projectId = projectId;
+    }
+
+    public GoogleBigQueryConnectionFactoryNestedConfiguration getConnectionFactory() {
+        return connectionFactory;
+    }
+
+    public void setConnectionFactory(
+            GoogleBigQueryConnectionFactoryNestedConfiguration connectionFactory) {
+        this.connectionFactory = connectionFactory;
+    }
+
+    public Boolean getResolvePropertyPlaceholders() {
+        return resolvePropertyPlaceholders;
+    }
+
+    public void setResolvePropertyPlaceholders(
+            Boolean resolvePropertyPlaceholders) {
+        this.resolvePropertyPlaceholders = resolvePropertyPlaceholders;
+    }
+
+    public static class GoogleBigQueryConnectionFactoryNestedConfiguration {
+        public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.google.bigquery.GoogleBigQueryConnectionFactory.class;
+    }
+}
\ No newline at end of file
diff --git a/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/resources/META-INF/spring.factories b/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/resources/META-INF/spring.factories
index 6f6a9e7..14ead81 100644
--- a/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/resources/META-INF/spring.factories
+++ b/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/resources/META-INF/spring.factories
@@ -16,4 +16,6 @@
 ## ---------------------------------------------------------------------------
 
 org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-org.apache.camel.component.google.bigquery.springboot.GoogleBigQueryComponentAutoConfiguration
+org.apache.camel.component.google.bigquery.springboot.GoogleBigQueryComponentAutoConfiguration,\
+org.apache.camel.component.google.bigquery.sql.springboot.GoogleBigQuerySQLComponentAutoConfiguration
+


[camel] 03/03: CAMEL-12930 - Regen

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 98c7873443f4942a52f16c779fad6da3ed34e880
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Nov 28 13:17:41 2018 +0100

    CAMEL-12930 - Regen
---
 .../src/main/docs/google-bigquery-sql-component.adoc              | 8 ++++----
 components/readme.adoc                                            | 5 ++++-
 docs/user-manual/en/SUMMARY.md                                    | 1 +
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/components/camel-google-bigquery/src/main/docs/google-bigquery-sql-component.adoc b/components/camel-google-bigquery/src/main/docs/google-bigquery-sql-component.adoc
index 23f5df6..36d7cb8 100644
--- a/components/camel-google-bigquery/src/main/docs/google-bigquery-sql-component.adoc
+++ b/components/camel-google-bigquery/src/main/docs/google-bigquery-sql-component.adoc
@@ -123,16 +123,16 @@ with the following path and query parameters:
 === Spring Boot Auto-Configuration
 
 
-The component supports 4 options, which are listed below.
+The component supports 3 options, which are listed below.
 
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *camel.component.google-bigquery-sql.enabled* | Whether to enable auto configuration of the google-bigquery component. This is enabled by default. |  | Boolean
+| *camel.component.google-bigquery-sql.enabled* | Whether to enable auto configuration of the google-bigquery-sql component. This is enabled by default. |  | Boolean
 | *camel.component.google-bigquery-sql.project-id* | Google Cloud Project Id |  | String
-//| *camel.component.google-bigquery.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
+| *camel.component.google-bigquery-sql.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
 |===
 // spring-boot-auto-configure options: END
 
@@ -148,4 +148,4 @@ The component supports 4 options, which are listed below.
 
 ### Producer Endpoints
 
-Google BigQuery SQL endpoint expects the payload to be either empty or a map of query parameters.
\ No newline at end of file
+Google BigQuery SQL endpoint expects the payload to be either empty or a map of query parameters.
diff --git a/components/readme.adoc b/components/readme.adoc
index 17c953b..c79457d 100644
--- a/components/readme.adoc
+++ b/components/readme.adoc
@@ -2,7 +2,7 @@ Components
 ^^^^^^^^^^
 
 // components: START
-Number of Components: 307 in 208 JAR artifacts (22 deprecated)
+Number of Components: 308 in 208 JAR artifacts (22 deprecated)
 
 [width="100%",cols="4,1,5",options="header"]
 |===
@@ -299,6 +299,9 @@ Number of Components: 307 in 208 JAR artifacts (22 deprecated)
 | link:camel-google-bigquery/src/main/docs/google-bigquery-component.adoc[Google BigQuery] (camel-google-bigquery) +
 `google-bigquery:projectId:datasetId:tableName` | 2.20 | Google BigQuery data warehouse for analytics.
 
+| link:camel-google-bigquery/src/main/docs/google-bigquery-sql-component.adoc[Google BigQuery Standard SQL] (camel-google-bigquery) +
+`google-bigquery-sql:query` | 2.23 | Google BigQuery data warehouse for analytics. BigQuery Endpoint Definition Represents a table within a BigQuery dataset Contains configuration details for a single table and the utility methods (such as check, create) to ease operations URI Parameters: Logger ID - To ensure that logging is unified under Route Logger, the logger ID can be passed on via an endpoint URI parameter Partitioned - to indicate that the table needs to be partitioned - every UT [...]
+
 | link:camel-google-calendar/src/main/docs/google-calendar-component.adoc[Google Calendar] (camel-google-calendar) +
 `google-calendar:apiName/methodName` | 2.15 | The google-calendar component provides access to Google Calendar.
 
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index a1893cf..03ab164 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -255,6 +255,7 @@
 	* [Git](git-component.adoc)
 	* [GitHub](github-component.adoc)
 	* [Google BigQuery](google-bigquery-component.adoc)
+	* [Google BigQuery Standard SQL](google-bigquery-sql-component.adoc)
 	* [Google Calendar](google-calendar-component.adoc)
 	* [Google Calendar Stream](google-calendar-stream-component.adoc)
 	* [Google Drive](google-drive-component.adoc)


[camel] 01/03: CAMEL-12930 - Ability to execute DML statements in Google Bigquery component, thanks to Roman Lusnikov for the patch

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 87b501575c882800f0b0e673c2ab3d45ca03810d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Nov 28 12:02:15 2018 +0100

    CAMEL-12930 - Ability to execute DML statements in Google Bigquery component, thanks to Roman Lusnikov for the patch
---
 .../main/docs/google-bigquery-sql-component.adoc   | 151 +++++++++++++++++++
 .../google/bigquery/GoogleBigQueryConstants.java   |   1 +
 .../bigquery/sql/GoogleBigQuerySQLComponent.java   |  81 +++++++++++
 .../sql/GoogleBigQuerySQLConfiguration.java        |  76 ++++++++++
 .../bigquery/sql/GoogleBigQuerySQLEndpoint.java    |  80 +++++++++++
 .../bigquery/sql/GoogleBigQuerySQLProducer.java    | 159 +++++++++++++++++++++
 .../component/google/bigquery/sql/SqlHelper.java   |  94 ++++++++++++
 .../org/apache/camel/component/google-bigquery-sql |  18 +++
 .../integration/sql/SqlQueryFromResourceTest.java  |  85 +++++++++++
 .../bigquery/integration/sql/SqlQueryTest.java     |  85 +++++++++++
 .../unit/sql/GoogleBigQuerySQLComponentTest.java   |  52 +++++++
 .../sql/GoogleBigQuerySQLProducerBaseTest.java     |  44 ++++++
 .../GoogleBigQuerySQLProducerWithParamersTest.java |  91 ++++++++++++
 .../GoogleBigQuerySQLProducerWithPatternTest.java  |  69 +++++++++
 .../google/bigquery/unit/sql/SqlHelperTest.java    | 113 +++++++++++++++
 .../src/test/resources/sql/delete.sql              |   1 +
 .../src/test/resources/sql/insert.sql              |   2 +
 17 files changed, 1202 insertions(+)

diff --git a/components/camel-google-bigquery/src/main/docs/google-bigquery-sql-component.adoc b/components/camel-google-bigquery/src/main/docs/google-bigquery-sql-component.adoc
new file mode 100644
index 0000000..23f5df6
--- /dev/null
+++ b/components/camel-google-bigquery/src/main/docs/google-bigquery-sql-component.adoc
@@ -0,0 +1,151 @@
+[[google-bigquery-sql-component]]
+== Google BigQuery Standard SQL Component
+== Google BigQuery Component
+*Available as of Camel version 2.23*
+
+### Component Description
+
+The Google Bigquery SQL component provides access
+to https://cloud.google.com/bigquery/[Cloud BigQuery Infrastructure] via
+the https://developers.google.com/apis-explorer/#p/bigquery/v2/bigquery.jobs.query[Google Client Services API].
+
+The current implementation supports only standard SQL
+https://cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax[DML queries].
+
+Maven users will need to add the following dependency to their pom.xml
+for this component:
+
+[source,xml]
+------------------------------------------------------
+<dependency>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-google-bigquery</artifactId>
+    <version>x.x.x</version>
+    <!-- use the same version as your Camel core version -->
+</dependency>
+
+------------------------------------------------------
+
+[[GoogleBigQuery-AuthenticationConfiguration]]
+
+### Authentication Configuration
+
+Google BigQuery component authentication is targeted for use with the GCP Service Accounts.
+For more information please refer to https://cloud.google.com/docs/authentication[Google Cloud Platform Auth Guide]
+
+Google security credentials can be set explicitly via one of the two options:
+
+* Service Account Email and Service Account Key (PEM format)
+* GCP credentials file location
+
+If both are set, the Service Account Email/Key will take precedence.
+
+Or implicitly, where the connection factory falls back on
+https://developers.google.com/identity/protocols/application-default-credentials#howtheywork[Application Default Credentials].
+
+*OBS!* The location of the default credentials file is configurable - via GOOGLE_APPLICATION_CREDENTIALS environment variable.
+
+Service Account Email and Service Account Key can be found in the GCP JSON credentials file as client_email and private_key respectively.
+
+### URI Format
+
+[source,java]
+--------------------------------------------------------
+        google-bigquery-sql://project-id:query?[options]
+--------------------------------------------------------
+
+Examples:
+[source,java]
+--------------------------------------------------------
+        google-bigquery-sql://project-17248459:delete * from test.table where id=@myId
+        google-bigquery-sql://project-17248459:delete * from ${datasetId}.${tableId} where id=@myId
+--------------------------------------------------------
+where
+
+ * parameters in form ${name} are extracted from message headers and formed the translated query
+ * parameters in form @name are extracted from body or message headers and sent to Google Bigquery
+
+You can externalize your SQL queries to files in the classpath or file system as shown:
+[source,java]
+--------------------------------------------------------
+        google-bigquery-sql://project-17248459::classpath:delete.sql
+--------------------------------------------------------
+
+
+
+### Options
+
+// component options: START
+The Google BigQuery Standard SQL component supports 3 options, which are listed below.
+
+
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *projectId* (producer) | Google Cloud Project Id |  | String
+| *connectionFactory* (producer) | ConnectionFactory to obtain connection to Bigquery Service. If non provided the default one will be used |  | GoogleBigQuery ConnectionFactory
+| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
+|===
+// component options: END
+
+// endpoint options: START
+The Google BigQuery Standard SQL endpoint is configured using URI syntax:
+
+----
+google-bigquery-sql:query
+----
+
+with the following path and query parameters:
+
+==== Path Parameters (2 parameters):
+
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *projectId* | *Required* Google Cloud Project Id |  | String
+| *query* | *Required* BigQuery standard SQL query |  | String
+|===
+
+
+==== Query Parameters (2 parameters):
+
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *connectionFactory* (producer) | ConnectionFactory to obtain connection to Bigquery Service. If non provided the default will be used. |  | GoogleBigQuery ConnectionFactory
+| *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
+|===
+// endpoint options: END
+// spring-boot-auto-configure options: START
+=== Spring Boot Auto-Configuration
+
+
+The component supports 4 options, which are listed below.
+
+
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *camel.component.google-bigquery-sql.enabled* | Whether to enable auto configuration of the google-bigquery component. This is enabled by default. |  | Boolean
+| *camel.component.google-bigquery-sql.project-id* | Google Cloud Project Id |  | String
+//| *camel.component.google-bigquery.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
+|===
+// spring-boot-auto-configure options: END
+
+
+### Ouput Message Headers
+
+[width="100%",cols="10%,10%,80%",options="header",]
+|=======================================================================
+|Name |Type |Description
+|`CamelGoogleBigQueryTranslatedQuery` |`String` | Preprocessed query text
+|=======================================================================
+
+
+### Producer Endpoints
+
+Google BigQuery SQL endpoint expects the payload to be either empty or a map of query parameters.
\ No newline at end of file
diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConstants.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConstants.java
index cfd3c57..945cde7 100644
--- a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConstants.java
+++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/GoogleBigQueryConstants.java
@@ -21,6 +21,7 @@ public final class GoogleBigQueryConstants {
     public static final String TABLE_ID = "CamelGoogleBigQueryTableId";
     public static final String INSERT_ID = "CamelGoogleBigQueryInsertId";
     public static final String PARTITION_DECORATOR = "CamelGoogleBigQueryPartitionDecorator";
+    public static final String TRANSLATED_QUERY = "CamelGoogleBigQueryTranslatedQuery";
 
     /**
      * Prevent instantiation.
diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLComponent.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLComponent.java
new file mode 100644
index 0000000..fcbcf66
--- /dev/null
+++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLComponent.java
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.google.bigquery.sql;
+
+import java.util.Map;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.component.google.bigquery.GoogleBigQueryConnectionFactory;
+import org.apache.camel.impl.DefaultComponent;
+
+public class GoogleBigQuerySQLComponent extends DefaultComponent {
+    private String projectId;
+    private GoogleBigQueryConnectionFactory connectionFactory;
+
+    public GoogleBigQuerySQLComponent() {
+        super();
+    }
+
+    public GoogleBigQuerySQLComponent(CamelContext camelContext) {
+        super(camelContext);
+    }
+
+    // Endpoint represents a single table
+    @Override
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        String[] parts = remaining.split(":");
+
+        if (parts.length < 2) {
+            throw new IllegalArgumentException("Google BigQuery Endpoint format \"projectId:<query>\"");
+        }
+
+        GoogleBigQuerySQLConfiguration configuration = new GoogleBigQuerySQLConfiguration();
+        setProperties(configuration, parameters);
+        configuration.parseRemaining(remaining);
+
+        if (configuration.getConnectionFactory() == null) {
+            configuration.setConnectionFactory(getConnectionFactory());
+        }
+
+        return new GoogleBigQuerySQLEndpoint(uri, this, configuration);
+    }
+
+    public String getProjectId() {
+        return projectId;
+    }
+
+    /**
+     * Google Cloud Project Id
+     */
+    public void setProjectId(String projectId) {
+        this.projectId = projectId;
+    }
+
+    public GoogleBigQueryConnectionFactory getConnectionFactory() {
+        if (connectionFactory == null) {
+            connectionFactory = new GoogleBigQueryConnectionFactory();
+        }
+        return connectionFactory;
+    }
+
+    /**
+     * ConnectionFactory to obtain connection to Bigquery Service. If non provided the default one will be used
+     */
+    public void setConnectionFactory(GoogleBigQueryConnectionFactory connectionFactory) {
+        this.connectionFactory = connectionFactory;
+    }
+}
diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLConfiguration.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLConfiguration.java
new file mode 100644
index 0000000..25ed0dff
--- /dev/null
+++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLConfiguration.java
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.google.bigquery.sql;
+
+import org.apache.camel.component.google.bigquery.GoogleBigQueryConnectionFactory;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+import org.apache.camel.spi.UriPath;
+
+@UriParams
+public class GoogleBigQuerySQLConfiguration {
+
+    @UriParam(description = "ConnectionFactory to obtain connection to Bigquery Service. If non provided the default one will be used")
+    private GoogleBigQueryConnectionFactory connectionFactory;
+    @UriPath(label = "common", description = "Google Cloud Project Id")
+    @Metadata(required = "true")
+    private String projectId;
+    @UriPath(label = "common", description = "BigQuery standard SQL query")
+    @Metadata(required = "true")
+    private String query;
+
+    public void parseRemaining(String remaining) {
+        int indexOfColon = remaining.indexOf(":");
+
+        if (indexOfColon < 0) {
+            throw new IllegalArgumentException("Google BigQuery Endpoint format \"projectId:query\"");
+        }
+
+        projectId = remaining.substring(0, indexOfColon);
+        query = remaining.substring(indexOfColon + 1);
+    }
+
+    /**
+     * ConnectionFactory to obtain connection to Bigquery Service. If non provided the default will be used.
+     */
+    public GoogleBigQueryConnectionFactory getConnectionFactory() {
+        return connectionFactory;
+    }
+
+    public void setConnectionFactory(GoogleBigQueryConnectionFactory connectionFactory) {
+        this.connectionFactory = connectionFactory;
+    }
+
+    public String getQuery() {
+        return query;
+    }
+
+    public GoogleBigQuerySQLConfiguration setQuery(String query) {
+        this.query = query;
+        return this;
+    }
+
+    public String getProjectId() {
+        return projectId;
+    }
+
+    public GoogleBigQuerySQLConfiguration setProjectId(String projectId) {
+        this.projectId = projectId;
+        return this;
+    }
+}
diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLEndpoint.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLEndpoint.java
new file mode 100644
index 0000000..fee9e96
--- /dev/null
+++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLEndpoint.java
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.google.bigquery.sql;
+
+import com.google.api.services.bigquery.Bigquery;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+
+/**
+ * Google BigQuery data warehouse for analytics.
+ * 
+ * BigQuery Endpoint Definition
+ * Represents a table within a BigQuery dataset
+ * Contains configuration details for a single table and the utility methods (such as check, create) to ease operations
+ * URI Parameters:
+ * * Logger ID - To ensure that logging is unified under Route Logger, the logger ID can be passed on
+ *               via an endpoint URI parameter
+ * * Partitioned - to indicate that the table needs to be partitioned - every UTC day to be written into a
+ *                 timestamped separate table
+ *                 side effect: Australian operational day is always split between two UTC days, and, therefore, tables
+ *
+ * Another consideration is that exceptions are not handled within the class. They are expected to bubble up and be handled
+ * by Camel.
+ */
+@UriEndpoint(firstVersion = "2.23.0", scheme = "google-bigquery-sql", title = "Google BigQuery Standard SQL", syntax = "google-bigquery-sql:query",
+    label = "cloud,messaging", producerOnly = true)
+public class GoogleBigQuerySQLEndpoint extends DefaultEndpoint {
+
+    @UriParam
+    protected final GoogleBigQuerySQLConfiguration configuration;
+
+    protected GoogleBigQuerySQLEndpoint(String endpointUri, GoogleBigQuerySQLComponent component, GoogleBigQuerySQLConfiguration configuration) {
+        super(endpointUri, component);
+        this.configuration = configuration;
+    }
+
+    @Override
+    public Producer createProducer() throws Exception {
+        Bigquery bigquery = getConfiguration().getConnectionFactory().getDefaultClient();
+        GoogleBigQuerySQLProducer producer = new GoogleBigQuerySQLProducer(bigquery, this, configuration);
+        return producer;
+    }
+
+    public Consumer createConsumer(Processor processor) throws Exception {
+        throw new UnsupportedOperationException("Cannot consume from the BigQuery endpoint: " + getEndpointUri());
+    }
+
+    public boolean isSingleton() {
+        return true;
+    }
+
+    public GoogleBigQuerySQLConfiguration getConfiguration() {
+        return configuration;
+    }
+
+    @Override
+    public GoogleBigQuerySQLComponent getComponent() {
+        return (GoogleBigQuerySQLComponent)super.getComponent();
+    }
+
+
+}
diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLProducer.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLProducer.java
new file mode 100644
index 0000000..e9ce93d
--- /dev/null
+++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLProducer.java
@@ -0,0 +1,159 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements.  See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.  You may obtain a
+ * copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.camel.component.google.bigquery.sql;
+
+import com.google.api.services.bigquery.Bigquery;
+import com.google.api.services.bigquery.model.*;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.RuntimeExchangeException;
+import org.apache.camel.component.google.bigquery.GoogleBigQueryConstants;
+import org.apache.camel.impl.DefaultProducer;
+
+import java.util.*;
+
+/**
+ * Generic BigQuery Producer
+ */
+public class GoogleBigQuerySQLProducer extends DefaultProducer {
+
+    private final GoogleBigQuerySQLConfiguration configuration;
+    private Bigquery bigquery;
+    private String query;
+    private Set<String> queryParameterNames;
+
+    public GoogleBigQuerySQLProducer(Bigquery bigquery, GoogleBigQuerySQLEndpoint endpoint,
+                                     GoogleBigQuerySQLConfiguration configuration) {
+        super(endpoint);
+        this.bigquery = bigquery;
+        this.configuration = configuration;
+    }
+
+    /**
+     * Process the exchange
+     *
+     * The incoming exchange can be a grouped exchange in which case all the exchanges will be combined.
+     *
+     * The incoming can be
+     * <ul>
+     *     <li>A map where all map keys will map to field records. One map object maps to one bigquery row</li>
+     *     <li>A list of maps. Each entry in the list will map to one bigquery row</li>
+     * </ul>
+     * The incoming message is expected to be a List of Maps
+     * The assumptions:
+     * - All incoming records go into the same table
+     * - Incoming records sorted by the timestamp
+     */
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        String translatedQuery = SqlHelper.translateQuery(query, exchange);
+        Map<String, Object> queryParameters = extractParameters(exchange);
+        exchange.getMessage().setHeader(GoogleBigQueryConstants.TRANSLATED_QUERY, translatedQuery);
+        Long affectedRows = executeSQL(translatedQuery, queryParameters);
+        log.debug("The query {} affected {} rows", query, affectedRows);
+        exchange.getMessage().setBody(affectedRows);
+    }
+
+    private Long executeSQL(String translatedQuery, Map<String, Object> queryParameters) throws Exception {
+        QueryRequest apiQueryRequest = new QueryRequest()
+                .setQuery(translatedQuery)
+                .setUseLegacySql(false);
+
+        Bigquery.Jobs.Query apiQuery = bigquery
+                .jobs()
+                .query(configuration.getProjectId(), apiQueryRequest);
+
+        setQueryParameters(queryParameters, apiQueryRequest);
+
+        if (log.isTraceEnabled()) {
+            log.trace("Sending query to bigquery standard sql: {}",
+                    translatedQuery);
+        }
+
+        QueryResponse apiResponse = apiQuery.execute();
+
+        if (apiResponse.getErrors() != null && !apiResponse.getErrors().isEmpty()) {
+            throw new Exception("Query " + translatedQuery + " failed: " + apiResponse.getErrors());
+        }
+
+        if (log.isTraceEnabled()) {
+            log.trace("Result of query {} is {}",
+                    translatedQuery, apiResponse.toPrettyString());
+        }
+        return apiResponse.getNumDmlAffectedRows();
+    }
+
+    private Map<String, Object> extractParameters(Exchange exchange) {
+        if (queryParameterNames == null || queryParameterNames.size() == 0)
+            return null;
+
+        Message message = exchange.getMessage();
+
+        HashMap<String, Object> headers = new HashMap<>(message.getHeaders());
+        if (message.getBody() instanceof Map) {
+            try {
+                headers.putAll(message.getBody(Map.class));
+            } catch (ClassCastException e) {
+                e.printStackTrace();
+            }
+        }
+
+        HashMap<String, Object> result = new HashMap<>(queryParameterNames.size());
+        queryParameterNames.forEach(s -> {
+            Object value = headers.get(s);
+            if (value == null) {
+                throw new RuntimeExchangeException("SQL parameter with name '" + s + "' not found in the message headers", exchange);
+            }
+
+            result.put(s, headers.get(s));
+        });
+
+        return result;
+    }
+
+    private void setQueryParameters(Map<String, Object> params, QueryRequest apiQueryRequest) {
+        if (params == null)
+            return;
+
+        List<QueryParameter> list = new ArrayList<>();
+        params.forEach((key, value) -> {
+            QueryParameter param = new QueryParameter();
+            param.setName(key)
+                    .setParameterType(new QueryParameterType().setType("STRING"))
+                    .setParameterValue(new QueryParameterValue().setValue(value.toString()));
+            list.add(param);
+        });
+        apiQueryRequest.setQueryParameters(list);
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+    @Override
+    public GoogleBigQuerySQLEndpoint getEndpoint() {
+        return (GoogleBigQuerySQLEndpoint) super.getEndpoint();
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        String placeholder = ":#"; // TODO
+        query = SqlHelper
+                .resolveQuery(getEndpoint().getCamelContext(), configuration.getQuery(), placeholder);
+        queryParameterNames = SqlHelper.extractParameterNames(query);
+    }
+}
diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/SqlHelper.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/SqlHelper.java
new file mode 100644
index 0000000..eb41856
--- /dev/null
+++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/SqlHelper.java
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.google.bigquery.sql;
+
+import org.apache.camel.*;
+import org.apache.camel.util.ResourceHelper;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public final class SqlHelper {
+
+    private static Pattern pattern = Pattern.compile("\\$\\{(\\w+)}");
+    private static Pattern parameterPattern = Pattern.compile("@(\\w+)");
+
+    private SqlHelper() {
+    }
+
+    /**
+     * Resolve the query by loading the query from the classpath or file resource if needed.
+     */
+    public static String resolveQuery(CamelContext camelContext, String query, String placeholder) throws NoTypeConversionAvailableException, IOException {
+        String answer = query;
+        if (ResourceHelper.hasScheme(query)) {
+            InputStream is = ResourceHelper
+                    .resolveMandatoryResourceAsInputStream(camelContext, query);
+            answer = camelContext.getTypeConverter().mandatoryConvertTo(String.class, is);
+            if (placeholder != null) {
+                answer = answer.replaceAll(placeholder, "@");
+            }
+        }
+        return answer;
+    }
+
+    /**
+     * Replaces pattern in query in form of "${param}" with values from message header
+     * Raises an error if param value not found in headers
+     * @param exchange
+     * @return Translated query text
+     */
+    public static String translateQuery(String query, Exchange exchange) {
+        Message message = exchange.getMessage();
+        Matcher matcher = pattern.matcher(query);
+        StringBuffer stringBuffer = new StringBuffer();
+        while (matcher.find()) {
+            String paramKey = matcher.group(1);
+
+            String value = message.getHeader(paramKey, String.class);
+            if (value == null) {
+                value = exchange.getProperty(paramKey, String.class);
+                if (value == null)
+                    throw new RuntimeExchangeException("SQL pattern with name '" + paramKey + "' not found in the message headers", exchange);
+            }
+
+            String replacement = Matcher.quoteReplacement(value);
+            matcher.appendReplacement(stringBuffer, replacement);
+        }
+        matcher.appendTail(stringBuffer);
+        return stringBuffer.toString();
+    }
+
+    /**
+     * Extracts list of parameters in form "@name" from query text
+     * @param query
+     * @return list of parameter names
+     */
+    public static Set<String> extractParameterNames(String query) {
+        Matcher matcher = parameterPattern.matcher(query);
+        Set<String> result = new HashSet<>();
+        while (matcher.find()) {
+            String paramName = matcher.group(1);
+            result.add(paramName);
+        }
+        return result;
+    }
+}
diff --git a/components/camel-google-bigquery/src/main/resources/META-INF/services/org/apache/camel/component/google-bigquery-sql b/components/camel-google-bigquery/src/main/resources/META-INF/services/org/apache/camel/component/google-bigquery-sql
new file mode 100644
index 0000000..1bf97f0
--- /dev/null
+++ b/components/camel-google-bigquery/src/main/resources/META-INF/services/org/apache/camel/component/google-bigquery-sql
@@ -0,0 +1,18 @@
+## ------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ------------------------------------------------------------------------
+
+class=org.apache.camel.component.google.bigquery.sql.GoogleBigQuerySQLComponent
diff --git a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQueryFromResourceTest.java b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQueryFromResourceTest.java
new file mode 100644
index 0000000..1ea8f46
--- /dev/null
+++ b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQueryFromResourceTest.java
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.google.bigquery.integration.sql;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.google.bigquery.integration.BigQueryTestSupport;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SqlQueryFromResourceTest extends BigQueryTestSupport {
+    private static final String TABLE_ID = "test_sql_table";
+
+    @EndpointInject(uri = "direct:in")
+    private Endpoint directIn;
+
+    @EndpointInject(uri = "google-bigquery-sql:{{project.id}}:classpath:sql/insert.sql")
+    private Endpoint bigqueryEndpoint;
+
+    @EndpointInject(uri = "mock:sendResult")
+    private MockEndpoint sendResult;
+
+    @Produce(uri = "direct:in")
+    private ProducerTemplate producer;
+
+    @Before
+    public void init() throws Exception {
+        createBqTable(TABLE_ID);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from(directIn)
+                        .routeId("InsertRow")
+                        .to(bigqueryEndpoint)
+                        .to(sendResult);
+            }
+        };
+    }
+
+    @Test
+    public void insertRecordBySql() throws Exception {
+        Exchange exchange = new DefaultExchange(context);
+        String uuidCol1 = UUID.randomUUID().toString();
+        String uuidCol2 = UUID.randomUUID().toString();
+
+        Map<String, String> object = new HashMap<>();
+        object.put("col1", uuidCol1);
+        object.put("col2", uuidCol2);
+        exchange.getIn().setBody(object);
+
+        sendResult.expectedMessageCount(1);
+        sendResult.expectedBodiesReceived(1);
+        producer.send(exchange);
+        sendResult.assertIsSatisfied(4000);
+
+        assertRowExist(TABLE_ID, object);
+    }
+
+}
diff --git a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQueryTest.java b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQueryTest.java
new file mode 100644
index 0000000..fc490e5
--- /dev/null
+++ b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/integration/sql/SqlQueryTest.java
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.google.bigquery.integration.sql;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.google.bigquery.integration.BigQueryTestSupport;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SqlQueryTest extends BigQueryTestSupport {
+    private static final String TABLE_ID = "test_sql_table";
+
+    @EndpointInject(uri = "direct:in")
+    private Endpoint directIn;
+
+    @EndpointInject(uri = "google-bigquery-sql:{{project.id}}: insert into {{bigquery.datasetId}}." + TABLE_ID + "(col1, col2) values (@col1, @col2)")
+    private Endpoint bigqueryEndpoint;
+
+    @EndpointInject(uri = "mock:sendResult")
+    private MockEndpoint sendResult;
+
+    @Produce(uri = "direct:in")
+    private ProducerTemplate producer;
+
+    @Before
+    public void init() throws Exception {
+        createBqTable(TABLE_ID);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from(directIn)
+                        .routeId("InsertRow")
+                        .to(bigqueryEndpoint)
+                        .to(sendResult);
+            }
+        };
+    }
+
+    @Test
+    public void insertRecordBySql() throws Exception {
+        Exchange exchange = new DefaultExchange(context);
+        String uuidCol1 = UUID.randomUUID().toString();
+        String uuidCol2 = UUID.randomUUID().toString();
+
+        Map<String, String> object = new HashMap<>();
+        object.put("col1", uuidCol1);
+        object.put("col2", uuidCol2);
+        exchange.getIn().setBody(object);
+
+        sendResult.expectedMessageCount(1);
+        sendResult.expectedBodiesReceived(1);
+        producer.send(exchange);
+        sendResult.assertIsSatisfied(4000);
+
+        assertRowExist(TABLE_ID, object);
+    }
+
+}
diff --git a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLComponentTest.java b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLComponentTest.java
new file mode 100644
index 0000000..ba24d0d
--- /dev/null
+++ b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLComponentTest.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.google.bigquery.unit.sql;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.google.bigquery.GoogleBigQueryComponent;
+import org.apache.camel.component.google.bigquery.GoogleBigQueryEndpoint;
+import org.apache.camel.component.google.bigquery.sql.GoogleBigQuerySQLComponent;
+import org.apache.camel.component.google.bigquery.sql.GoogleBigQuerySQLEndpoint;
+import org.apache.camel.component.google.bigquery.sql.SqlHelper;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class GoogleBigQuerySQLComponentTest {
+    private CamelContext context = Mockito.mock(CamelContext.class);
+
+    @Test
+    public void testQuerySet() throws Exception {
+        String uri = "google-bigquery-sql:myproject:insert into testDatasetId.testTableId(id) values(1)";
+
+        GoogleBigQuerySQLEndpoint endpoint = (GoogleBigQuerySQLEndpoint)new GoogleBigQuerySQLComponent(context).createEndpoint(uri);
+
+        assertEquals("myproject", endpoint.getConfiguration().getProjectId());
+        assertEquals("insert into testDatasetId.testTableId(id) values(1)", endpoint.getConfiguration().getQuery());
+    }
+
+    @Test
+    public void testQueryFromResourceSet() throws Exception {
+        String uri = "google-bigquery-sql:myproject:classpath:sql/delete.sql";
+
+        GoogleBigQuerySQLEndpoint endpoint = (GoogleBigQuerySQLEndpoint)new GoogleBigQuerySQLComponent(context).createEndpoint(uri);
+
+        assertEquals("myproject", endpoint.getConfiguration().getProjectId());
+        assertEquals("classpath:sql/delete.sql", endpoint.getConfiguration().getQuery());
+    }
+}
diff --git a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerBaseTest.java b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerBaseTest.java
new file mode 100644
index 0000000..244f27c
--- /dev/null
+++ b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerBaseTest.java
@@ -0,0 +1,44 @@
+package org.apache.camel.component.google.bigquery.unit.sql;
+
+import com.google.api.services.bigquery.Bigquery;
+import com.google.api.services.bigquery.model.QueryResponse;
+import org.apache.camel.component.google.bigquery.sql.GoogleBigQuerySQLConfiguration;
+import org.apache.camel.component.google.bigquery.sql.GoogleBigQuerySQLEndpoint;
+import org.apache.camel.component.google.bigquery.sql.GoogleBigQuerySQLProducer;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class GoogleBigQuerySQLProducerBaseTest extends CamelTestSupport {
+    protected GoogleBigQuerySQLEndpoint endpoint = mock(GoogleBigQuerySQLEndpoint.class);
+    protected Bigquery.Jobs mockJobs = mock(Bigquery.Jobs.class);
+    protected Bigquery.Jobs.Query mockQuery = mock(Bigquery.Jobs.Query.class);
+    protected GoogleBigQuerySQLProducer producer;
+    protected String sql;
+    protected String projectId = "testProjectId";
+    protected GoogleBigQuerySQLConfiguration configuration = new GoogleBigQuerySQLConfiguration();
+    protected Bigquery bigquery;
+
+    protected GoogleBigQuerySQLProducer createAndStartProducer() throws Exception {
+        configuration.setProjectId(projectId);
+        configuration.setQuery(sql);
+
+        GoogleBigQuerySQLProducer sqlProducer = new GoogleBigQuerySQLProducer(bigquery, endpoint, configuration);
+        sqlProducer.start();
+        return sqlProducer;
+    }
+
+    protected void setupBigqueryMock() throws Exception {
+        bigquery = mock(Bigquery.class);
+
+        when(bigquery.jobs()).thenReturn(mockJobs);
+        when(bigquery.jobs().query(anyString(), any())).thenReturn(mockQuery);
+
+        QueryResponse mockResponse = new QueryResponse()
+                .setNumDmlAffectedRows(1L);
+        when(mockQuery.execute()).thenReturn(mockResponse);
+    }
+}
diff --git a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithParamersTest.java b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithParamersTest.java
new file mode 100644
index 0000000..6227dfb
--- /dev/null
+++ b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithParamersTest.java
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.google.bigquery.unit.sql;
+
+import com.google.api.services.bigquery.model.QueryRequest;
+import org.apache.camel.Exchange;
+import org.apache.camel.RuntimeExchangeException;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.verify;
+
+public class GoogleBigQuerySQLProducerWithParamersTest extends GoogleBigQuerySQLProducerBaseTest {
+
+    @Before
+    public void init() throws Exception {
+        sql = "insert into testDatasetId.testTableId(id, data) values(@id, @data)";
+        setupBigqueryMock();
+        producer = createAndStartProducer();
+    }
+
+    @Test
+    public void sendMessageWithParametersInBody() throws Exception {
+        Map<String, String> body = new HashMap<>();
+        body.put("id", "100");
+        body.put("data", "some data");
+        producer.process(createExchangeWithBody(body));
+
+        ArgumentCaptor<QueryRequest> dataCaptor = ArgumentCaptor.forClass(QueryRequest.class);
+        verify(bigquery.jobs()).query(eq(projectId), dataCaptor.capture());
+
+        QueryRequest request = dataCaptor.getValue();
+        assertEquals(sql, request.getQuery());
+        assertEquals(2, request.getQueryParameters().size());
+
+        assertEquals("id", request.getQueryParameters().get(1).getName());
+        assertEquals("100", request.getQueryParameters().get(1).getParameterValue().getValue());
+
+        assertEquals("data", request.getQueryParameters().get(0).getName());
+        assertEquals("some data", request.getQueryParameters().get(0).getParameterValue().getValue());
+    }
+
+    @Test
+    public void sendMessageWithParametersInBodyAndHeaders() throws Exception {
+        Map<String, String> body = new HashMap<>();
+        body.put("id", "100");
+
+        Exchange exchange = createExchangeWithBody(body);
+        exchange.getMessage().getHeaders().put("id", "200");
+        exchange.getMessage().getHeaders().put("data", "some data");
+
+        producer.process(exchange);
+
+        ArgumentCaptor<QueryRequest> dataCaptor = ArgumentCaptor.forClass(QueryRequest.class);
+        verify(bigquery.jobs()).query(eq(projectId), dataCaptor.capture());
+
+        QueryRequest request = dataCaptor.getValue();
+        assertEquals(sql, request.getQuery());
+        assertEquals(2, request.getQueryParameters().size());
+
+        assertEquals("id", request.getQueryParameters().get(1).getName());
+        assertEquals("Body data must have higher priority", "100", request.getQueryParameters().get(1).getParameterValue().getValue());
+
+        assertEquals("data", request.getQueryParameters().get(0).getName());
+        assertEquals("some data", request.getQueryParameters().get(0).getParameterValue().getValue());
+    }
+
+    @Test(expected = RuntimeExchangeException.class)
+    public void sendMessageWithoutParameters() throws Exception {
+        producer.process(createExchangeWithBody(new HashMap<>()));
+    }
+}
diff --git a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithPatternTest.java b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithPatternTest.java
new file mode 100644
index 0000000..11cb050
--- /dev/null
+++ b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithPatternTest.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.google.bigquery.unit.sql;
+
+import com.google.api.services.bigquery.model.QueryRequest;
+import org.apache.camel.Exchange;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import java.util.List;
+
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.verify;
+
+public class GoogleBigQuerySQLProducerWithPatternTest extends GoogleBigQuerySQLProducerBaseTest {
+
+    @Before
+    public void init() throws Exception {
+        sql = "insert into ${testDatasetId}.testTableId(id, data) values(1, 'test')";
+        setupBigqueryMock();
+        producer = createAndStartProducer();
+    }
+
+    @Test
+    public void sendExchangeWithProperties() throws Exception {
+        Exchange exchange = createExchangeWithBody(null);
+        exchange.getProperties().put("testDatasetId", "dataset");
+        String expected = "insert into dataset.testTableId(id, data) values(1, 'test')";
+        producer.process(exchange);
+
+        ArgumentCaptor<QueryRequest> dataCaptor = ArgumentCaptor.forClass(QueryRequest.class);
+        verify(bigquery.jobs()).query(eq(projectId), dataCaptor.capture());
+
+        List<QueryRequest> requests = dataCaptor.getAllValues();
+        assertEquals(1, requests.size());
+        assertEquals(expected, requests.get(0).getQuery());
+    }
+
+    @Test
+    public void sendMessageWithHeaders() throws Exception {
+        Exchange exchange = createExchangeWithBody(null);
+        exchange.getMessage().getHeaders().put("testDatasetId", "dataset");
+        String expected = "insert into dataset.testTableId(id, data) values(1, 'test')";
+        producer.process(exchange);
+
+        ArgumentCaptor<QueryRequest> dataCaptor = ArgumentCaptor.forClass(QueryRequest.class);
+        verify(bigquery.jobs()).query(eq(projectId), dataCaptor.capture());
+
+        List<QueryRequest> requests = dataCaptor.getAllValues();
+        assertEquals(1, requests.size());
+        assertEquals(expected, requests.get(0).getQuery());
+    }
+
+}
diff --git a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/SqlHelperTest.java b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/SqlHelperTest.java
new file mode 100644
index 0000000..de46355
--- /dev/null
+++ b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/SqlHelperTest.java
@@ -0,0 +1,113 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.google.bigquery.unit.sql;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.RuntimeExchangeException;
+import org.apache.camel.component.google.bigquery.sql.SqlHelper;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import java.util.Set;
+
+import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
+public class SqlHelperTest {
+    private CamelContext context = Mockito.mock(CamelContext.class);
+
+    @Test
+    public void testResolveQuery() throws Exception {
+        String answer = SqlHelper.resolveQuery(context, "delete from test.test_sql_table where id = 1", null);
+        assertEquals("delete from test.test_sql_table where id = 1", answer);
+    }
+
+    @Test
+    @Ignore
+    public void testResolveClasspathQuery() throws Exception {
+        String answer = SqlHelper.resolveQuery(context, "classpath:sql/delete.sql", ":");
+        assertEquals("delete from test.test_sql_table where id = @id", answer);
+    }
+
+    String query = "INSERT INTO ${report}.test( -- TODO \n" +
+            "  id,\n" +
+            "  region\n" +
+            ")\n" +
+            "SELECT\n" +
+            "  id,\n" +
+            "  region\n" +
+            "FROM\n" +
+            "  ${import}.test\n" +
+            "WHERE\n" +
+            "  rec_date = @date AND id = @id\n";
+
+    String expected = "INSERT INTO report_data.test( -- TODO \n" +
+            "  id,\n" +
+            "  region\n" +
+            ")\n" +
+            "SELECT\n" +
+            "  id,\n" +
+            "  region\n" +
+            "FROM\n" +
+            "  import_data.test\n" +
+            "WHERE\n" +
+            "  rec_date = @date AND id = @id\n";
+
+    Exchange exchange = Mockito.mock(Exchange.class);
+    Message message = Mockito.mock(Message.class);
+
+    @Test
+    public void testTranslateQuery() {
+        when(exchange.getMessage()).thenReturn(message);
+        when(message.getHeader(eq("report"), eq(String.class))).thenReturn("report_data");
+        when(message.getHeader(eq("import"), eq(String.class))).thenReturn("import_data");
+
+        String answer = SqlHelper.translateQuery(query, exchange);
+        assertEquals(expected, answer);
+    }
+
+    @Test
+    public void testTranslateQueryProperties() {
+        when(exchange.getMessage()).thenReturn(message);
+        when(exchange.getProperty(eq("report"), eq(String.class))).thenReturn("report_data");
+        when(exchange.getProperty(eq("import"), eq(String.class))).thenReturn("import_data");
+
+        String answer = SqlHelper.translateQuery(query, exchange);
+        assertEquals(expected, answer);
+    }
+
+    @Test(expected = RuntimeExchangeException.class)
+    public void testTranslateQueryWithoutParam() {
+        when(exchange.getMessage()).thenReturn(message);
+        when(message.getHeader(eq("report"), eq(String.class))).thenReturn("report_data");
+
+        SqlHelper.translateQuery(query, exchange);
+        fail("Should have thrown exception");
+    }
+
+    @Test
+    public void testExtractParameterNames() {
+        Set<String> answer = SqlHelper.extractParameterNames(query);
+        assertEquals(2, answer.size());
+        assertTrue("Parameter 'date' not found", answer.contains("date"));
+        assertTrue("Parameter 'id' not found", answer.contains("id"));
+    }
+}
diff --git a/components/camel-google-bigquery/src/test/resources/sql/delete.sql b/components/camel-google-bigquery/src/test/resources/sql/delete.sql
new file mode 100644
index 0000000..d074f55
--- /dev/null
+++ b/components/camel-google-bigquery/src/test/resources/sql/delete.sql
@@ -0,0 +1 @@
+delete from test.test_sql_table where id = :id
\ No newline at end of file
diff --git a/components/camel-google-bigquery/src/test/resources/sql/insert.sql b/components/camel-google-bigquery/src/test/resources/sql/insert.sql
new file mode 100644
index 0000000..74048aa
--- /dev/null
+++ b/components/camel-google-bigquery/src/test/resources/sql/insert.sql
@@ -0,0 +1,2 @@
+insert into test.test_sql_table (col1, col2)
+values (@col1, @col2)
\ No newline at end of file