Interface SqlDialect

    • Method Detail

      • getName

        String getName()
        Get the dialect name.
        Returns:
        name of the dialect
      • getCapabilities

        com.exasol.adapter.capabilities.Capabilities getCapabilities()
        Get the capabilities the SQL dialect supports.
        Returns:
        set of capabilities supported by this SQL-Dialect
      • supportsJdbcCatalogs

        SqlDialect.StructureElementSupport supportsJdbcCatalogs()
        Define whether the remote source supports catalogs and if it does, check if it supports a single "pseudo" catalog or multiple catalogs.
        Returns:
        NONE if the dialect does not support catalogs at all, SINGLE if it supports exactly one (like e.g. Exasol) or MULTIPLE if real catalogs are supported.
      • supportsJdbcSchemas

        SqlDialect.StructureElementSupport supportsJdbcSchemas()
        Define whether the remote source supports schemas and if it does, check if it supports a single "pseudo" schema or multiple schemas.
        Returns:
        NONE if the dialect does not support schemas at all, SINGLE if it supports exactly one (like e.g. Exasol) or MULTIPLE if real schemas are supported.
      • applyQuote

        String applyQuote​(String identifier)
        Parameters:
        identifier - The name of an identifier (table or column). If identifiers are case sensitive, the identifier must be passed case-sensitive of course.
        Returns:
        the quoted identifier, also if quoting is not required
      • requiresCatalogQualifiedTableNames

        boolean requiresCatalogQualifiedTableNames​(SqlGenerationContext context)
        Check whether the dialect expects table identifiers to be qualified with the catalog.

        Example:

        SELECT * FROM MY_CATALOG.MY_TABLE

        Can be combined with requiresSchemaQualifiedTableNames(SqlGenerationContext).

        Parameters:
        context - context for SQL generation
        Returns:
        true if table names must be catalog-qualified
      • requiresSchemaQualifiedTableNames

        boolean requiresSchemaQualifiedTableNames​(SqlGenerationContext context)
        Check whether the dialect expects table identifiers to be qualified with the schema.

        Example:

        SELECT * FROM MY_SCHEMA.MY_TABLE

        Can be combined with requiresCatalogQualifiedTableNames(SqlGenerationContext).

        Parameters:
        context - context for SQL generation
        Returns:
        true if table names must be schema-qualified
      • getTableCatalogAndSchemaSeparator

        String getTableCatalogAndSchemaSeparator()
        Returns:
        String that is used to separate the catalog and/or the schema from the table name. In many cases this is a dot.
      • getDefaultNullSorting

        SqlDialect.NullSorting getDefaultNullSorting()
        Returns:
        The behavior how nulls are sorted in an ORDER BY. If the null sorting behavior is not SqlDialect.NullSorting.NULLS_SORTED_AT_END and your dialects has the order by capability but you cannot explicitly specify NULLS FIRST or NULLS LAST, then you must overwrite the SQL generation to somehow obtain the desired semantic.
      • getStringLiteral

        String getStringLiteral​(String value)
        Parameters:
        value - a string literal value
        Returns:
        the string literal in valid SQL syntax, e.g. "value" becomes "'value'". This might include escaping.
      • getScalarFunctionAliases

        Map<com.exasol.adapter.sql.ScalarFunction,​String> getScalarFunctionAliases()
        Returns:
        aliases for scalar functions. To be defined for each function that has the same semantic but a different name in the data source. If an alias for the same function is defined in getBinaryInfixFunctionAliases(), than the infix alias will be ignored.
      • getBinaryInfixFunctionAliases

        Map<com.exasol.adapter.sql.ScalarFunction,​String> getBinaryInfixFunctionAliases()
        Returns:
        Defines which binary scalar functions should be treated infix and how. E.g. a map entry ("ADD", "+") causes a function call "ADD(1,2)" to be written as "1 + 2".
      • getPrefixFunctionAliases

        Map<com.exasol.adapter.sql.ScalarFunction,​String> getPrefixFunctionAliases()
        Returns:
        Defines which unary scalar functions should be treated prefix and how. E.g. a map entry ("NEG", "-") causes a function call "NEG(2)" to be written as "-2".
      • getAggregateFunctionAliases

        Map<com.exasol.adapter.sql.AggregateFunction,​String> getAggregateFunctionAliases()
        Returns:
        aliases for aggregate functions. To be defined for each function that has the same semantic but a different name in the data source.
      • omitParentheses

        boolean omitParentheses​(com.exasol.adapter.sql.ScalarFunction function)
        Check whether a parentheses should be omitted for a function.
        Parameters:
        function - function for which the necessity of parentheses is evaluated
        Returns:
        Returns true for functions with zero arguments if they do not require parentheses (e.g. SYSDATE).
      • getSqlGenerator

        SqlGenerator getSqlGenerator​(SqlGenerationContext context)
        Returns the Visitor to be used for SQL generation. Use this only if you need to, i.e. if you have requirements which cannot be realized via the other methods provided by SqlDialect.
        Parameters:
        context - context information for the SQL generation visitor
        Returns:
        the SqlGenerationVisitor to be used for this dialect
      • readSchemaMetadata

        com.exasol.adapter.metadata.SchemaMetadata readSchemaMetadata()
                                                               throws SQLException
        Read the remote schema metadata for all tables from the remote source.
        Returns:
        remote schema metadata
        Throws:
        SQLException - if reading the remote metadata fails
      • readSchemaMetadata

        com.exasol.adapter.metadata.SchemaMetadata readSchemaMetadata​(List<String> tables)
        Read the remote schema metadata for selected tables from the remote source.
        Parameters:
        tables - selected tables for which the metadata should be read
        Returns:
        remote schema metadata
      • rewriteQuery

        String rewriteQuery​(com.exasol.adapter.sql.SqlStatement statement,
                            List<com.exasol.adapter.metadata.DataType> selectListDataTypes,
                            com.exasol.ExaMetadata exaMetadata)
                     throws com.exasol.adapter.AdapterException,
                            SQLException
        Rewrite the given query so that data from the remote data source is imported into Exasol when that query is executed on the Virtual Schema frontend.
        Parameters:
        statement - original query as sent by the Virtual Schema frontend
        selectListDataTypes - expected datatypes of the result set
        exaMetadata - Exasol metadata
        Returns:
        rewritten query
        Throws:
        SQLException - if execution of any SQL command on the remote data source failed
        com.exasol.adapter.AdapterException - if rewriting the query failed