<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<spark-jdbc-configuration>
    <database name="h2">
        <tableCreateQuery>CREATE TABLE {{TABLE_NAME}} ({{COLUMNS, PRIMARY_KEYS}})</tableCreateQuery>
        <tableCheckQuery>SELECT 1 FROM {{TABLE_NAME}} LIMIT 1</tableCheckQuery>
        <tableTruncateQuery>TRUNCATE TABLE {{TABLE_NAME}}</tableTruncateQuery>
        <indexCreateQuery>CREATE INDEX {{TABLE_NAME}}_INDEX ON {{TABLE_NAME}} ({{INDEX_COLUMNS}})</indexCreateQuery>
        <recordInsertQuery>INSERT INTO {{TABLE_NAME}} VALUES ({{Q}})</recordInsertQuery>
        <recordMergeQuery>MERGE INTO {{TABLE_NAME}} ({{COLUMN}}) KEY ({{KEYS}}) VALUES ({{Q}})</recordMergeQuery>
        <typeMapping>
            <binaryType>BLOB</binaryType>
            <booleanType>TINYINT(1)</booleanType>
            <byteType>SMALLINT</byteType>
            <dateType>DATE</dateType>
            <doubleType>DOUBLE</doubleType>
            <floatType>FLOAT</floatType>
            <integerType>INTEGER</integerType>
            <longType>BIGINT</longType>
            <nullType>NULL</nullType>
            <shortType>SMALLINT</shortType>
            <stringType>VARCHAR(254)</stringType>
            <timestampType>DATETIME</timestampType>
        </typeMapping>
    </database>
    <database name="mysql">
        <tableCreateQuery>CREATE TABLE {{TABLE_NAME}} ({{COLUMNS, PRIMARY_KEYS}})</tableCreateQuery>
        <tableCheckQuery>SELECT 1 FROM {{TABLE_NAME}} LIMIT 1</tableCheckQuery>
        <tableTruncateQuery>TRUNCATE TABLE {{TABLE_NAME}}</tableTruncateQuery>
        <indexCreateQuery>CREATE INDEX {{TABLE_NAME}}_INDEX ON {{TABLE_NAME}} ({{INDEX_COLUMNS}})</indexCreateQuery>
        <recordInsertQuery>INSERT INTO {{TABLE_NAME}} VALUES ({{Q}})</recordInsertQuery>
        <recordMergeQuery>INSERT INTO {{TABLE_NAME}} VALUES ({{Q}}) ON DUPLICATE KEY UPDATE {{COLUMN=VALUES(COLUMN) - KEY}}</recordMergeQuery>
        <quoteMark>`</quoteMark>
        <typeMapping>
            <binaryType>BLOB</binaryType>
            <booleanType>TINYINT(1)</booleanType>
            <byteType>SMALLINT</byteType>
            <dateType>DATE</dateType>
            <doubleType>DOUBLE</doubleType>
            <floatType>FLOAT</floatType>
            <integerType>INTEGER</integerType>
            <longType>BIGINT</longType>
            <nullType>NULL</nullType>
            <shortType>SMALLINT</shortType>
            <stringType>VARCHAR(254)</stringType>
            <timestampType>DATETIME</timestampType>
        </typeMapping>
    </database>
    <database name="oracle">
        <tableCreateQuery>CREATE TABLE {{TABLE_NAME}} ({{COLUMNS, PRIMARY_KEYS}})</tableCreateQuery>
        <tableCheckQuery>SELECT 1 FROM {{TABLE_NAME}} WHERE rownum=1</tableCheckQuery>
        <tableTruncateQuery>TRUNCATE TABLE {{TABLE_NAME}}</tableTruncateQuery>
        <indexCreateQuery>CREATE INDEX {{TABLE_NAME}}_INDEX ON {{TABLE_NAME}} ({{INDEX_COLUMNS}})</indexCreateQuery>
        <recordInsertQuery>INSERT INTO {{TABLE_NAME}} VALUES ({{Q}})</recordInsertQuery>
        <recordMergeQuery>MERGE INTO {{TABLE_NAME}} dest USING( SELECT  {{Q COLUMN}} FROM dual) src ON({{D.KEY=S.KEY}})
            WHEN NOT MATCHED THEN INSERT({{COLUMN}}) VALUES({{S.COLUMN}}) WHEN MATCHED THEN UPDATE SET {{D.COLUMN=S.COLUMN - KEY}}</recordMergeQuery>
        <typeMapping>
            <binaryType>BLOB</binaryType>
            <booleanType>NUMBER(1)</booleanType>
            <byteType>NUMBER(3)</byteType>
            <dateType>DATE</dateType>
            <doubleType>NUMBER(19,4)</doubleType>
            <floatType>NUMBER(19,4)</floatType>
            <integerType>NUMBER(10)</integerType>
            <longType>NUMBER(19)</longType>
            <nullType>NULL</nullType>
            <shortType>NUMBER(5)</shortType>
            <stringType>VARCHAR(254)</stringType>
            <timestampType>DATE</timestampType>
        </typeMapping>
    </database>
    <database name="Microsoft SQL Server">
        <tableCreateQuery>CREATE TABLE {{TABLE_NAME}} ({{COLUMNS, PRIMARY_KEYS}})</tableCreateQuery>
        <tableCheckQuery>SELECT TOP 1 1 from {{TABLE_NAME}}</tableCheckQuery>
        <tableTruncateQuery>TRUNCATE TABLE {{TABLE_NAME}}</tableTruncateQuery>
        <indexCreateQuery>CREATE CLUSTERED INDEX {{TABLE_NAME}}_INDEX ON {{TABLE_NAME}} ({{INDEX_COLUMNS}})</indexCreateQuery>
        <recordInsertQuery>INSERT INTO {{TABLE_NAME}} VALUES ({{Q}})</recordInsertQuery>
        <recordMergeQuery>MERGE {{TABLE_NAME}} AS dest USING (SELECT {{Q}}) AS src ({{COLUMN}}) ON ({{D.KEY=S.KEY}})
            WHEN MATCHED THEN UPDATE SET {{COLUMN=S.COLUMN}} WHEN NOT MATCHED THEN INSERT({{COLUMN}}) VALUES ({{S.COLUMN}});</recordMergeQuery>
        <typeMapping>
            <binaryType>VARBINARY(max)</binaryType>
            <booleanType>BIT</booleanType>
            <byteType>SMALLINT</byteType>
            <dateType>DATETIME</dateType>
            <doubleType>FLOAT(32)</doubleType>
            <floatType>REAL</floatType>
            <integerType>INTEGER</integerType>
            <longType>BIGINT</longType>
            <nullType>NULL</nullType>
            <shortType>SMALLINT</shortType>
            <stringType>VARCHAR(254)</stringType>
            <timestampType>DATETIME</timestampType>
        </typeMapping>
    </database>
    <database name="PostgreSQL">
        <tableCreateQuery>CREATE TABLE {{TABLE_NAME}} ({{COLUMNS, PRIMARY_KEYS}})</tableCreateQuery>
        <tableCheckQuery>SELECT 1 FROM {{TABLE_NAME}} LIMIT 1</tableCheckQuery>
        <tableTruncateQuery>TRUNCATE TABLE {{TABLE_NAME}}</tableTruncateQuery>
        <indexCreateQuery>CREATE INDEX {{TABLE_NAME}}_INDEX ON {{TABLE_NAME}} ({{INDEX_COLUMNS}})</indexCreateQuery>
        <recordInsertQuery>INSERT INTO {{TABLE_NAME}} VALUES ({{Q}})</recordInsertQuery>
        <recordMergeQuery>INSERT INTO {{TABLE_NAME}} ({{COLUMN}}) VALUES ({{Q}}) ON CONFLICT ({{KEYS}}) DO UPDATE SET {{COLUMN=EXCLUDED.COLUMN - KEY}}</recordMergeQuery>
        <typeMapping>
            <binaryType>BYTEA</binaryType>
            <booleanType>BOOLEAN</booleanType>
            <byteType>TINYINT</byteType>
            <dateType>DATE</dateType>
            <doubleType>DOUBLE PRECISION</doubleType>
            <floatType>REAL</floatType>
            <integerType>INTEGER</integerType>
            <longType>BIGINT</longType>
            <nullType>NULL</nullType>
            <shortType>SMALLINT</shortType>
            <stringType>VARCHAR(254)</stringType>
            <timestampType>TIMESTAMP</timestampType>
        </typeMapping>
    </database>
    <database name="DB2.*">
        <tableCreateQuery>CREATE TABLE {{TABLE_NAME}} ({{COLUMNS, PRIMARY_KEYS}})</tableCreateQuery>
        <tableCheckQuery>SELECT 1 FROM {{TABLE_NAME}} FETCH FIRST 1 ROWS ONLY</tableCheckQuery>
        <tableTruncateQuery>TRUNCATE TABLE {{TABLE_NAME}} IMMEDIATE</tableTruncateQuery>
        <indexCreateQuery>CREATE INDEX {{TABLE_NAME}}_INDEX ON {{TABLE_NAME}} ({{INDEX_COLUMNS}})</indexCreateQuery>
        <recordInsertQuery>INSERT INTO {{TABLE_NAME}} VALUES ({{Q}})</recordInsertQuery>
        <recordMergeQuery>MERGE INTO {{TABLE_NAME}} AS dest USING (VALUES({{Q}})) AS src ({{COLUMN}}) ON {{D.KEY=S.KEY}} WHEN MATCHED THEN UPDATE SET {{D.COLUMN=S.COLUMN - KEY}} WHEN NOT MATCHED THEN INSERT ({{COLUMN}}) VALUES ({{S.COLUMN}})</recordMergeQuery>
        <keyExplicitNotNull>true</keyExplicitNotNull>
        <typeMapping>
            <binaryType>BLOB(64000)</binaryType>
            <booleanType>SMALLINT</booleanType>
            <byteType>SMALLINT</byteType>
            <dateType>DATE</dateType>
            <doubleType>DOUBLE</doubleType>
            <floatType>REAL</floatType>
            <integerType>INTEGER</integerType>
            <longType>BIGINT</longType>
            <nullType>NULL</nullType>
            <shortType>SMALLINT</shortType>
            <stringType>VARCHAR(254)</stringType>
            <timestampType>TIMESTAMP</timestampType>
        </typeMapping>
    </database>
</spark-jdbc-configuration>