Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#314: implemented switch for IMPORT statement for BigQuery dialect #315

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/dialects/athena.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The SQL statement below creates the adapter script, defines the Java class that
```sql
CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.0.2.jar;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.1.0.jar;
%jar /buckets/<BFS service>/<bucket>/AthenaJDBC42-<JDBC driver version>.jar;
/
;
Expand Down
2 changes: 1 addition & 1 deletion doc/dialects/aurora.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ The SQL statement below creates the adapter script, defines the Java class that
```sql
CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.0.2.jar;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.1.0.jar;
%jar /buckets/<BFS service>/<bucket>/postgresql-<JDBC driver version>.jar;
/
```
Expand Down
8 changes: 7 additions & 1 deletion doc/dialects/bigquery.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Please remember to check the versions of your JAR files after downloading driver
```sql
CREATE JAVA ADAPTER SCRIPT SCHEMA_FOR_VS_SCRIPT.ADAPTER_SCRIPT_BIGQUERY AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.0.2.jar;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.1.0.jar;
%jar /buckets/<BFS service>/<bucket>/avro-1.8.2.jar;
%jar /buckets/<BFS service>/<bucket>/gax-1.42.0.jar;
%jar /buckets/<BFS service>/<bucket>/google-api-client-1.28.0.jar;
Expand Down Expand Up @@ -101,6 +101,12 @@ If you need to use currently unsupported data types or find a way around known l
## Performance

Please be aware that the current implementation of the dialect can only handle result sets with limited size (a few thousand rows).
If you need to proceed a large amount of data, please, contact our support team. Another implementation of the dialect with a speed improvement(using IMPORT INTO) is available, but not documented and announced officially on our GitHub due to:
AnastasiiaSergienko marked this conversation as resolved.
Show resolved Hide resolved

1. the complex installation process
2. security risks (a user has to disable the drivers' security manager to use it)

Please, try to avoid using IMPORT implementation if it is possible. Be aware of the security risks.
AnastasiiaSergienko marked this conversation as resolved.
Show resolved Hide resolved

## Testing information

Expand Down
4 changes: 2 additions & 2 deletions doc/dialects/db2.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The SQL statement below creates the adapter script, defines the Java class that
```sql
CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.0.2.jar;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.1.0.jar;
%jar /buckets/<BFS service>/<bucket>/db2jcc4.jar;
%jar /buckets/<BFS service>/<bucket>/db2jcc_license_cu.jar;
/
Expand All @@ -68,7 +68,7 @@ CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
```sql
CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.0.2.jar;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.1.0.jar;
%jar /buckets/<BFS service>/<bucket>/db2jcc4.jar;
%jar /buckets/<BFS service>/<bucket>/db2jcc_license_cu.jar;
%jar /buckets/<BFS service>/<bucket>/db2jcc_license_cisuz.jar;
Expand Down
2 changes: 1 addition & 1 deletion doc/dialects/exasol.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The SQL statement below creates the adapter script, defines the Java class that
```sql
CREATE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.0.2.jar;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.1.0.jar;
/
```

Expand Down
2 changes: 1 addition & 1 deletion doc/dialects/hive.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The SQL statement below creates the adapter script, defines the Java class that
```sql
CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/jars/virtualschema-jdbc-adapter-dist-3.0.2.jar;
%jar /buckets/<BFS service>/<bucket>/jars/virtualschema-jdbc-adapter-dist-3.1.0.jar;
%jar /buckets/<BFS service>/<bucket>/jars/HiveJDBC41.jar;
/
```
Expand Down
2 changes: 1 addition & 1 deletion doc/dialects/impala.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The SQL statement below creates the adapter script, defines the Java class that
```sql
CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.0.2.jar;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.1.0.jar;
%jar /buckets/<BFS service>/<bucket>/ImpalaJDBC41.jar;
/
;
Expand Down
2 changes: 1 addition & 1 deletion doc/dialects/mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The SQL statement below creates the adapter script, defines the Java class that
```sql
CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.0.2.jar;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.1.0.jar;
%jar /buckets/<BFS service>/<bucket>/mysql-connector-java-<version>.jar;
/
;
Expand Down
2 changes: 1 addition & 1 deletion doc/dialects/oracle.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The SQL statement below creates the adapter script, defines the Java class that
```sql
CREATE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.0.2.jar;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.1.0.jar;
%jar /buckets/<BFS service>/<bucket>/ojdbc<JDBC driver version>.jar;
/
;
Expand Down
2 changes: 1 addition & 1 deletion doc/dialects/postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The SQL statement below creates the adapter script, defines the Java class that
```sql
CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.0.2.jar;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.1.0.jar;
%jar /buckets/<BFS service>/<bucket>/postgresql-<version>.jar;
/
```
Expand Down
2 changes: 1 addition & 1 deletion doc/dialects/redshift.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The SQL statement below creates the adapter script, defines the Java class that
```sql
CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.0.2.jar;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.1.0.jar;
%jar /buckets/<BFS service>/<bucket>/RedshiftJDBC42-<JDBC driver version>.jar;
/
;
Expand Down
2 changes: 1 addition & 1 deletion doc/dialects/saphana.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The SQL statement below creates the adapter script, defines the Java class that
```sql
CREATE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.0.2.jar;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.1.0.jar;
%jar /buckets/<BFS service>/<bucket>/ngdbc-<JDBC driver version>.jar;
/
;
Expand Down
2 changes: 1 addition & 1 deletion doc/dialects/sql_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The SQL statement below creates the adapter script, defines the Java class that
```sql
CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.0.2.jar;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.1.0.jar;
%jar /buckets/<BFS service>/<bucket>/jtds.jar;
/
```
Expand Down
2 changes: 1 addition & 1 deletion doc/dialects/sybase.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The SQL statement below creates the adapter script, defines the Java class that
```sql
CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.0.2.jar;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.1.0.jar;
%jar /buckets/<BFS service>/<bucket>/jtds-<version>.jar;
/
```
Expand Down
2 changes: 1 addition & 1 deletion doc/dialects/teradata.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The SQL statement below creates the adapter script, defines the Java class that
```sql
CREATE OR REPLACE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.0.2.jar;
%jar /buckets/<BFS service>/<bucket>/virtualschema-jdbc-adapter-dist-3.1.0.jar;
%jar /buckets/<BFS service>/<bucket>/terajdbc4.jar;
%jar /buckets/<BFS service>/<bucket>/tdgssconfig.jar;
/
Expand Down
8 changes: 4 additions & 4 deletions doc/user-guide/deploying_the_virtual_schema_adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cd virtual-schemas/jdbc-adapter/
mvn clean -DskipTests package
```

The resulting fat JAR is stored in `virtualschema-jdbc-adapter-dist/target/virtualschema-jdbc-adapter-dist-3.0.2.jar`.
The resulting fat JAR is stored in `virtualschema-jdbc-adapter-dist/target/virtualschema-jdbc-adapter-dist-3.1.0.jar`.

## Uploading the Adapter JAR Archive

Expand All @@ -46,8 +46,8 @@ Following steps are required to upload a file to a bucket:
1. Now upload the file into this bucket, e.g. using curl (adapt the hostname, BucketFS port, bucket name and bucket write password).

```bash
curl -X PUT -T virtualschema-jdbc-adapter-dist/target/virtualschema-jdbc-adapter-dist-3.0.2.jar \
http://w:[email protected]:2580/bucket1/virtualschema-jdbc-adapter-dist-3.0.2.jar
curl -X PUT -T virtualschema-jdbc-adapter-dist/target/virtualschema-jdbc-adapter-dist-3.1.0.jar \
http://w:[email protected]:2580/bucket1/virtualschema-jdbc-adapter-dist-3.1.0.jar
```

If you later need to change the bucket passwords, select the bucket and click "Edit".
Expand Down Expand Up @@ -84,7 +84,7 @@ CREATE SCHEMA ADAPTER;

CREATE JAVA ADAPTER SCRIPT ADAPTER.JDBC_ADAPTER AS
%scriptclass com.exasol.adapter.RequestDispatcher;
%jar /buckets/your-bucket-fs/your-bucket/virtualschema-jdbc-adapter-dist-3.0.2.jar;
%jar /buckets/your-bucket-fs/your-bucket/virtualschema-jdbc-adapter-dist-3.1.0.jar;
%jar /buckets/your-bucket-fs/your-bucket/<JDBC driver>.jar;
/
```
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<version>${product.version}</version>
<name>Virtual Schema JDBC Adapter</name>
<properties>
<product.version>3.0.2</product.version>
<product.version>3.1.0</product.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public BigQueryColumnMetadataReader(final Connection connection, final AdapterPr
@Override
public DataType mapJdbcType(final JdbcTypeDescription jdbcTypeDescription) {
if (jdbcTypeDescription.getJdbcType() == Types.TIME) {
return DataType.createVarChar(16, DataType.ExaCharset.UTF8);
return DataType.createVarChar(30, DataType.ExaCharset.UTF8);
}
return super.mapJdbcType(jdbcTypeDescription);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public Set<String> getSupportedTableTypes() {

@Override
protected IdentifierConverter createIdentifierConverter() {
return new BaseIdentifierConverter(IdentifierCaseHandling.INTERPRET_AS_UPPER,
return new BaseIdentifierConverter(IdentifierCaseHandling.INTERPRET_AS_LOWER,
IdentifierCaseHandling.INTERPRET_CASE_SENSITIVE);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.exasol.adapter.dialects.bigquery;

/**
* This class contains BigQuery-specific adapter properties.
*/
public class BigQueryProperties {
public static final String BIGQUERY_ENABLE_IMPORT_PROPERTY = "BIGQUERY_ENABLE_IMPORT";

private BigQueryProperties() {
// prevent instantiation
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import static com.exasol.adapter.capabilities.MainCapability.*;
import static com.exasol.adapter.capabilities.PredicateCapability.*;
import static com.exasol.adapter.capabilities.ScalarFunctionCapability.*;
import static com.exasol.adapter.dialects.bigquery.BigQueryProperties.BIGQUERY_ENABLE_IMPORT_PROPERTY;

import java.sql.Connection;
import java.util.*;
import java.util.logging.Logger;

import com.exasol.adapter.AdapterProperties;
import com.exasol.adapter.capabilities.Capabilities;
Expand All @@ -23,12 +25,13 @@
* @see <a href="https://cloud.google.com/bigquery/">BigQuery</a>
*/
public class BigQuerySqlDialect extends AbstractSqlDialect {
private static final Logger LOGGER = Logger.getLogger(BigQuerySqlDialect.class.getName());
static final String NAME = "BIGQUERY";
private static final Capabilities CAPABILITIES = createCapabilityList();
private static final List<String> SUPPORTED_PROPERTIES = Arrays.asList(SQL_DIALECT_PROPERTY,
CONNECTION_NAME_PROPERTY, CONNECTION_STRING_PROPERTY, USERNAME_PROPERTY, PASSWORD_PROPERTY,
CATALOG_NAME_PROPERTY, SCHEMA_NAME_PROPERTY, TABLE_FILTER_PROPERTY, EXCLUDED_CAPABILITIES_PROPERTY,
DEBUG_ADDRESS_PROPERTY, LOG_LEVEL_PROPERTY);
DEBUG_ADDRESS_PROPERTY, LOG_LEVEL_PROPERTY, BIGQUERY_ENABLE_IMPORT_PROPERTY);

/**
* Create a new instance of the {@link BigQuerySqlDialect}.
Expand All @@ -48,7 +51,14 @@ protected RemoteMetadataReader createRemoteMetadataReader() {

@Override
protected QueryRewriter createQueryRewriter() {
return new BigQueryQueryRewriter(this, this.remoteMetadataReader, this.connection);
if (this.properties.containsKey(BIGQUERY_ENABLE_IMPORT_PROPERTY)
&& "true".equalsIgnoreCase(this.properties.get(BIGQUERY_ENABLE_IMPORT_PROPERTY))) {
LOGGER.warning("Attention: IMPORT is activated for the BIGQUERY dialect. "
+ "Please be aware that it using IMPORT with this dialect requires disabling important security features and is therefore not recommended!");
AnastasiiaSergienko marked this conversation as resolved.
Show resolved Hide resolved
return new BaseQueryRewriter(this, this.remoteMetadataReader, this.connection);
} else {
return new BigQueryQueryRewriter(this, this.remoteMetadataReader, this.connection);
}
}

@Override
Expand Down Expand Up @@ -135,7 +145,8 @@ public NullSorting getDefaultNullSorting() {
}

@Override
public SqlGenerationVisitor getSqlGenerationVisitor(final SqlGenerationContext context) {
return new BigQuerySqlGenerationVisitor(this, context);
public void validateProperties() throws PropertyValidationException {
super.validateProperties();
validateBooleanProperty(BIGQUERY_ENABLE_IMPORT_PROPERTY);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public final class IntegrationTestConstants {
public static final String INTEGRATION_TEST_CONFIGURATION_FILE_PROPERTY = "integrationtest.configfile";
public static final String VIRTUAL_SCHEMAS_JAR_NAME_AND_VERSION = "virtualschema-jdbc-adapter-dist-3.0.2.jar";
public static final String VIRTUAL_SCHEMAS_JAR_NAME_AND_VERSION = "virtualschema-jdbc-adapter-dist-3.1.0.jar";
public static final Path PATH_TO_VIRTUAL_SCHEMAS_JAR = Path.of("target", VIRTUAL_SCHEMAS_JAR_NAME_AND_VERSION);
public static final String SCHEMA_EXASOL = "SCHEMA_EXASOL";
public static final String ADAPTER_SCRIPT_EXASOL = "ADAPTER_SCRIPT_EXASOL";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ void beforeEach() {
void mapDecimalReturnDecimal() {
final JdbcTypeDescription typeDescription = new JdbcTypeDescription(Types.TIME, 0, 0, 10, "TIME");
assertThat(this.columnMetadataReader.mapJdbcType(typeDescription),
equalTo(DataType.createVarChar(16, DataType.ExaCharset.UTF8)));
equalTo(DataType.createVarChar(30, DataType.ExaCharset.UTF8)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ void testCreateIdentifierConverter() {
() -> assertThat(converter.getQuotedIdentifierHandling(),
equalTo(IdentifierCaseHandling.INTERPRET_CASE_SENSITIVE)),
() -> assertThat(converter.getUnquotedIdentifierHandling(),
equalTo(IdentifierCaseHandling.INTERPRET_AS_UPPER)));
equalTo(IdentifierCaseHandling.INTERPRET_AS_LOWER)));
}
}
Loading