Class AbstractQueryRewriter
- java.lang.Object
-
- com.exasol.adapter.dialects.rewriting.AbstractQueryRewriter
-
- All Implemented Interfaces:
QueryRewriter
- Direct Known Subclasses:
ImportFromJDBCQueryRewriter,ImportIntoTemporaryTableQueryRewriter
public abstract class AbstractQueryRewriter extends Object implements QueryRewriter
Abstract implementation ofQueryRewriter.
-
-
Field Summary
Fields Modifier and Type Field Description protected ConnectionDefinitionBuilderconnectionDefinitionBuilderConnection definition builderprotected SqlDialectdialectDialect implementationprotected RemoteMetadataReaderremoteMetadataReaderRemote metadata reader
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractQueryRewriter(SqlDialect dialect, RemoteMetadataReader remoteMetadataReader, ConnectionDefinitionBuilder connectionDefinitionBuilder)Create a new instance of aAbstractQueryRewriter.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract StringgenerateImportStatement(String connectionDefinition, String pushdownQuery)Generate an IMPORT statement to be executed in the Exasol database, using the passed pushdown query to be executed in the external source be as source data.protected StringgenerateImportStatement(String connectionDefinition, List<com.exasol.adapter.metadata.DataType> selectListDataTypes, String pushdownQuery)This method provides backwards compatibility.protected com.exasol.ExaConnectionInformationgetConnectionInformation(com.exasol.ExaMetadata exaMetadata, com.exasol.adapter.AdapterProperties properties)Read the connection information from the metadata.Stringrewrite(com.exasol.adapter.sql.SqlStatement statement, List<com.exasol.adapter.metadata.DataType> selectListDataTypes, com.exasol.ExaMetadata exaMetadata, com.exasol.adapter.AdapterProperties properties)Set the original push-down statement.
-
-
-
Field Detail
-
dialect
protected final SqlDialect dialect
Dialect implementation
-
remoteMetadataReader
protected final RemoteMetadataReader remoteMetadataReader
Remote metadata reader
-
connectionDefinitionBuilder
protected final ConnectionDefinitionBuilder connectionDefinitionBuilder
Connection definition builder
-
-
Constructor Detail
-
AbstractQueryRewriter
protected AbstractQueryRewriter(SqlDialect dialect, RemoteMetadataReader remoteMetadataReader, ConnectionDefinitionBuilder connectionDefinitionBuilder)
Create a new instance of aAbstractQueryRewriter.- Parameters:
dialect- dialectremoteMetadataReader- remote metadata readerconnectionDefinitionBuilder- builder for creating connection definitions
-
-
Method Detail
-
rewrite
public String rewrite(com.exasol.adapter.sql.SqlStatement statement, List<com.exasol.adapter.metadata.DataType> selectListDataTypes, com.exasol.ExaMetadata exaMetadata, com.exasol.adapter.AdapterProperties properties) throws com.exasol.adapter.AdapterException, SQLException
Description copied from interface:QueryRewriterSet the original push-down statement.- Specified by:
rewritein interfaceQueryRewriter- Parameters:
statement- SQL statement that represents the original push-down queryselectListDataTypes- expected data types of result setexaMetadata- Exasol metadataproperties- user-defined adapter properties- Returns:
- rewritten query
- Throws:
com.exasol.adapter.AdapterException- if rewriting failsSQLException- if any SQL commands executed on the remote data source failed during rewriting
-
getConnectionInformation
protected com.exasol.ExaConnectionInformation getConnectionInformation(com.exasol.ExaMetadata exaMetadata, com.exasol.adapter.AdapterProperties properties) throws com.exasol.adapter.AdapterExceptionRead the connection information from the metadata.- Parameters:
exaMetadata- metadataproperties- adapter properties- Returns:
- connection information
- Throws:
com.exasol.adapter.AdapterException- if access fails
-
generateImportStatement
protected String generateImportStatement(String connectionDefinition, List<com.exasol.adapter.metadata.DataType> selectListDataTypes, String pushdownQuery) throws SQLException
This method provides backwards compatibility. A class extending theAbstractQueryRewriterhas two options:- Option (O1): override the new method
generateImportStatement(String, List, String)enabling to use the new parameterselectListDataTypesto determine the data types of the result set of the query. - Option (O2): only override the old method
generateImportStatement(String, String)and by that falling back to the old way, i.e. inferring the data types of the result set by inspecting its values.
- Parameters:
connectionDefinition- connection definition to be used when connecting to the external sourceselectListDataTypes- expected data types of result setpushdownQuery- source data for the `IMPORT...FROM` statement- Returns:
- IMPORT statement to be executed on the Exasol database
- Throws:
SQLException- if any problem occurs
- Option (O1): override the new method
-
generateImportStatement
protected abstract String generateImportStatement(String connectionDefinition, String pushdownQuery) throws SQLException
Generate an IMPORT statement to be executed in the Exasol database, using the passed pushdown query to be executed in the external source be as source data.- Parameters:
connectionDefinition- connection definition to be used when connecting to the external sourcepushdownQuery- source data for the `IMPORT...FROM` statement- Returns:
- IMPORT statement to be executed on the Exasol database
- Throws:
SQLException- if any problem occurs
-
-