Skip to content

Commit

Permalink
Unified error messages with 'error-reporting-java' (#5)
Browse files Browse the repository at this point in the history
* #3: Unified error messages with 'error-reporting-java'
  • Loading branch information
chiaradiamarcelo authored Feb 15, 2021
1 parent d2f23a8 commit ed0f5c2
Show file tree
Hide file tree
Showing 22 changed files with 154 additions and 281 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Running the Virtual Schema requires a Java Runtime version 11 or later.
| [Maven Dependency Plugin][maven-dependency-plugin] | Accessing to test dependencies | Apache License 2.0 |
| [Artifact Reference Checker Plugin][artifact-ref-checker-plugin] | Check if artifact is referenced with correct version | MIT License |
| [Project Keeper Maven Plugin][project-keeper-maven-plugin] | Checking project structure | MIT License |
| [Error Code Crawler Plugin][error-code-crawler-plugin] | Analyzing used error messages | MIT License |
| [Sonatype OSS Index Maven Plugin][sonatype-oss-index-maven-plugin] | Checking dependencies vulnerability | ASL2 |

[virtual-schema-common-jdbc]: https://github.com/exasol/virtual-schema-common-jdbc
Expand All @@ -101,6 +102,7 @@ Running the Virtual Schema requires a Java Runtime version 11 or later.
[artifact-ref-checker-plugin]: https://github.com/exasol/artifact-reference-checker-maven-plugin
[maven-dependency-plugin]: https://maven.apache.org/plugins/maven-dependency-plugin/
[project-keeper-maven-plugin]: https://github.com/exasol/project-keeper-maven-plugin
[error-code-crawler-plugin]: https://github.com/exasol/error-code-crawler-maven-plugin
[sonatype-oss-index-maven-plugin]: https://sonatype.github.io/ossindex-maven/maven-plugin/

[virtual-schemas-user-guide]: https://docs.exasol.com/database_concepts/virtual_schemas.htm
Expand Down
1 change: 1 addition & 0 deletions doc/changes/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Changes

* [2.0.0](changes_2.0.0.md)
* [1.0.0](changes_1.0.0.md)
17 changes: 17 additions & 0 deletions doc/changes/changes_2.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Oracle Virtual Schemas 2.0.0, released 2021-??-??

Code name:

## Summary

The `SQL_DIALECT` property used when executing a `CREATE VIRTUAL SCHEMA` from the Exasol database is obsolete from this version. Please, do not provide this property anymore.

## Features / Enhancements

* 3: Unified error messages with `error-reporting-java`

## Plugin Dependencies

* Added `com.exasol:error-code-crawler-maven-plugin:0.1.1`
* Updated `com.exasol:error-reporting-java:0.2.0` to `0.2.2`
* Updated `com.exasol:virtual-schema-common-jdbc:8.0.0` to `9.0.1`
9 changes: 3 additions & 6 deletions doc/user_guide/oracle_user_guide.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>/virtual-schema-dist-8.0.0-oracle-1.0.0.jar;
%jar /buckets/<BFS service>/<bucket>/virtual-schema-dist-9.0.1-oracle-2.0.0.jar;
%jar /buckets/<BFS service>/<bucket>/ojdbc<JDBC driver version>.jar;
/
;
Expand Down Expand Up @@ -80,7 +80,6 @@ Below you see how an Oracle Virtual Schema is created.
CREATE VIRTUAL SCHEMA <virtual schema name>
USING ADAPTER.JDBC_ADAPTER
WITH
SQL_DIALECT = 'ORACLE'
CONNECTION_NAME = 'ORACLE_JDBC_CONNECTION'
SCHEMA_NAME = '<schema name>';
```
Expand Down Expand Up @@ -126,7 +125,6 @@ Assuming you already setup the JDBC connection `ORACLE_JDBC_CONNECTION` as shown
CREATE VIRTUAL SCHEMA <virtual schema name>
USING ADAPTER.JDBC_ADAPTER
WITH
SQL_DIALECT = 'ORACLE'
CONNECTION_NAME = 'ORACLE_JDBC_CONNECTION'
SCHEMA_NAME = '<schema name>'
IMPORT_FROM_ORA = 'true'
Expand Down Expand Up @@ -179,7 +177,6 @@ For example:
CREATE VIRTUAL SCHEMA <virtual schema name>
USING ADAPTER.JDBC_ADAPTER
WITH
SQL_DIALECT = 'ORACLE'
CONNECTION_NAME = 'ORACLE_JDBC_CONNECTION'
SCHEMA_NAME = '<schema name>'
IMPORT_FROM_ORA = 'true'
Expand All @@ -206,11 +203,11 @@ Therefore we cannot include the MySQL JDBC driver, so in order to execute the in

### Starting Disabled Integration Test Locally

1. Download a JDBC driver and the Orcal instant client from:
1. Download a JDBC driver and the Oracle instant client from:
- Oracle [`ojdbc8.jar`](https://www.oracle.com/database/technologies/appdev/jdbc-ucp-19c-downloads.html)
- Oracle instant client [`instantclient-basic-linux.x64-12.1.0.2.0.zip`](https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html).
Please be aware that Exasol currently supports only mentioned version of the Oracle instant client.
2. Temporarily put the files into `src/test/resources/integration/driver/oracle` directory.
3. If the files' names are different (you renamed the file, or it has a different version number, for example) from the mentioned above, edit `src/test/resources/integration/driver/oracle/oracle.properties` and `settings.cfg` files.
4. Run the tests from an IDE or temporarily add the integration test name into the `maven-failsafe-plugin`'s includes a section and execute `mvn verify` command.
5. Remove the driver after the test and **do not upload it to the GitHub repository**.
5. Remove the driver after the test and **do not upload it to the GitHub repository**.
5 changes: 5 additions & 0 deletions errorCodeConfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
error-tags:
VS-ORA:
packages:
- com.exasol.adapter.dialects.oracle
highest-index: 1
20 changes: 17 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.exasol</groupId>
<artifactId>oracle-virtual-schema</artifactId>
<version>1.0.0</version>
<version>2.0.0</version>
<name>Virtual Schema for Oracle</name>
<distributionManagement>
<repository>
Expand All @@ -19,7 +19,9 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version>
<surefire.and.failsafe.plugin.version>3.0.0-M3</surefire.and.failsafe.plugin.version>
<vscjdbc.version>8.0.0</vscjdbc.version>
<vscjdbc.version>9.0.1</vscjdbc.version>
<error.reporting.java.version>0.2.2</error.reporting.java.version>
<error.code.crawler.version>0.1.1</error.code.crawler.version>
<org.testcontainers.version>1.15.0</org.testcontainers.version>
<sonar.coverage.jacoco.xmlReportPaths>target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml
</sonar.coverage.jacoco.xmlReportPaths>
Expand Down Expand Up @@ -54,7 +56,7 @@
<dependency>
<groupId>com.exasol</groupId>
<artifactId>error-reporting-java</artifactId>
<version>0.2.0</version>
<version>${error.reporting.java.version}</version>
</dependency>
<!--Unit test dependencies -->
<dependency>
Expand Down Expand Up @@ -294,6 +296,18 @@
</modules>
</configuration>
</plugin>
<plugin>
<groupId>com.exasol</groupId>
<artifactId>error-code-crawler-maven-plugin</artifactId>
<version>${error.code.crawler.version}</version>
<executions>
<execution>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.ossindex.maven</groupId>
<artifactId>ossindex-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.exasol.adapter.AdapterProperties;
import com.exasol.adapter.dialects.IdentifierConverter;
import com.exasol.adapter.jdbc.BaseColumnMetadataReader;
import com.exasol.adapter.jdbc.JdbcTypeDescription;
import com.exasol.adapter.jdbc.JDBCTypeDescription;
import com.exasol.adapter.metadata.DataType;

/**
Expand Down Expand Up @@ -36,7 +36,7 @@ public OracleColumnMetadataReader(final Connection connection, final AdapterProp
}

@Override
public DataType mapJdbcType(final JdbcTypeDescription jdbcTypeDescription) {
public DataType mapJdbcType(final JDBCTypeDescription jdbcTypeDescription) {
switch (jdbcTypeDescription.getJdbcType()) {
case Types.DECIMAL:
case Types.NUMERIC:
Expand All @@ -54,7 +54,7 @@ public DataType mapJdbcType(final JdbcTypeDescription jdbcTypeDescription) {
}
}

protected DataType mapNumericType(final JdbcTypeDescription jdbcTypeDescription) {
protected DataType mapNumericType(final JDBCTypeDescription jdbcTypeDescription) {
final int decimalScale = jdbcTypeDescription.getDecimalScale();
if (decimalScale == ORACLE_MAGIC_NUMBER_SCALE) {
return workAroundNumberWithoutScaleAndPrecision();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.exasol.ExaConnectionInformation;
import com.exasol.adapter.AdapterProperties;
import com.exasol.adapter.jdbc.BaseConnectionDefinitionBuilder;
import com.exasol.errorreporting.ExaError;

/**
* This class implements an Oracle-specific connection definition builder.
Expand All @@ -25,9 +26,11 @@ private String buildImportFromOraConnectionDefinition(final AdapterProperties pr
if (properties.containsKey(ORACLE_CONNECTION_NAME_PROPERTY)) {
return buildOracleConnectionDefinitionFromOracleConnectionOnly(properties);
} else {
throw new IllegalArgumentException("If you enable IMPORT FROM ORA with property \"" + ORACLE_IMPORT_PROPERTY
+ "\" you also need to provide the name of an Oracle connection with \""
+ ORACLE_CONNECTION_NAME_PROPERTY + "\".");
throw new IllegalArgumentException(ExaError.messageBuilder("E-VS-ORA-3")
.message("If you enable IMPORT FROM ORA with property {{OracleImportProperty}} "
+ "you also need to provide the name of an Oracle connection with {{OracleConnectionNameProperty}}.")
.parameter("OracleImportProperty", ORACLE_IMPORT_PROPERTY)
.parameter("OracleConnectionNameProperty", ORACLE_CONNECTION_NAME_PROPERTY).toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Objects;

import com.exasol.db.Identifier;
import com.exasol.errorreporting.ExaError;

/**
* Represents an identifier in the Oracle database.
Expand Down Expand Up @@ -34,10 +35,11 @@ public static OracleIdentifier of(final String id) {
if (validate(id)) {
return new OracleIdentifier(id);
} else {
throw new AssertionError("E-ID-3: Unable to create identifier \"" + id //
+ "\" because it contains illegal characters." //
+ " For information about valid identifiers, please refer to" //
+ " https://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements008.htm");
throw new AssertionError(ExaError.messageBuilder("E-VS-ORA-2")
.message("Unable to create identifier {{id}} because it contains illegal characters." //
+ " For information about valid identifiers, please refer to" //
+ " https://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements008.htm")
.parameter("id", id).toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

import java.sql.SQLException;

import com.exasol.adapter.dialects.AbstractQueryRewriter;
import com.exasol.adapter.dialects.SqlDialect;
import com.exasol.adapter.jdbc.ConnectionDefinitionBuilder;
import com.exasol.adapter.dialects.rewriting.AbstractQueryRewriter;
import com.exasol.adapter.jdbc.RemoteMetadataReader;

/**
Expand All @@ -18,12 +17,7 @@ public class OracleQueryRewriter extends AbstractQueryRewriter {
* @param remoteMetadataReader reader for metadata from the remote data source
*/
public OracleQueryRewriter(final SqlDialect dialect, final RemoteMetadataReader remoteMetadataReader) {
super(dialect, remoteMetadataReader);
}

@Override
protected ConnectionDefinitionBuilder createConnectionDefinitionBuilder() {
return new OracleConnectionDefinitionBuilder();
super(dialect, remoteMetadataReader, new OracleConnectionDefinitionBuilder());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
import com.exasol.adapter.AdapterProperties;
import com.exasol.adapter.capabilities.Capabilities;
import com.exasol.adapter.dialects.*;
import com.exasol.adapter.dialects.rewriting.ImportIntoTemporaryTableQueryRewriter;
import com.exasol.adapter.dialects.rewriting.SqlGenerationContext;
import com.exasol.adapter.jdbc.*;
import com.exasol.adapter.metadata.DataType;
import com.exasol.adapter.sql.*;
import com.exasol.adapter.sql.AggregateFunction;
import com.exasol.adapter.sql.ScalarFunction;
import com.exasol.errorreporting.ExaError;

/**
* This class implements the Oracle SQL dialect.
Expand Down Expand Up @@ -109,7 +113,7 @@ private DataType getOracleNumberTypeFromProperty() {
}

@Override
public SqlNodeVisitor<String> getSqlGenerationVisitor(final SqlGenerationContext context) {
public SqlGenerator getSqlGenerator(final SqlGenerationContext context) {
return new OracleSqlGenerationVisitor(this, context);
}

Expand Down Expand Up @@ -160,8 +164,9 @@ protected RemoteMetadataReader createRemoteMetadataReader() {
try {
return new OracleMetadataReader(this.connectionFactory.getConnection(), this.properties);
} catch (final SQLException exception) {
throw new RemoteMetadataReaderException(
"Unable to create Oracle remote metadata reader. Caused by: " + exception.getMessage(), exception);
throw new RemoteMetadataReaderException(ExaError.messageBuilder("E-VS-ORA-1")
.message("Unable to create Oracle remote metadata reader. Caused by: {{cause}}")
.unquotedParameter("cause", exception.getMessage()).toString(), exception);
}
}

Expand All @@ -170,7 +175,7 @@ protected QueryRewriter createQueryRewriter() {
if (this.isImportFromOraEnabled()) {
return new OracleQueryRewriter(this, createRemoteMetadataReader());
}
return new ImportIntoQueryRewriter(this, createRemoteMetadataReader(), this.connectionFactory);
return new ImportIntoTemporaryTableQueryRewriter(this, createRemoteMetadataReader(), this.connectionFactory);
}

private boolean isImportFromOraEnabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public String getSqlDialectName() {
public SqlDialect createSqlDialect(final ConnectionFactory connectionFactory, final AdapterProperties properties) {
return new OracleSqlDialect(connectionFactory, properties);
}

@Override
public String getSqlDialectVersion() {
final VersionCollector versionCollector = new VersionCollector(
"META-INF/maven/com.exasol/mysql-virtual-schema/pom.properties");
public String getSqlDialectVersion() {
final VersionCollector versionCollector = new VersionCollector(
"META-INF/maven/com.exasol/oracle-virtual-schema/pom.properties");
return versionCollector.getVersionNumber();
}
}
}
Loading

0 comments on commit ed0f5c2

Please sign in to comment.