Java API

The API below is generated from the JavaDoc comments of the sources: the xmldoc Gradle task runs the XML Doclet and writes _static/javadoc.xml, which the sphinx-javadoc-xml extension renders here with cross-links into the OpenJDK JavaDoc.

Regenerate the API description
gradle xmldoc

Package com.manticore.jdbc.parquetwriter

Classes

Class

Description

JDBCParquetWriter

The JDBC parquet writer class.

TableNamesFinder

Splits the tables of a statement into the one DML target table and the source tables feeding it. The traversal itself is left entirely to ``TablesNamesFinder``: the overrides below only record the target table on the way through and then delegate. Re-implementing the DML visitors here means missing every clause JSqlParser adds later (RETURNING, FOR PORTION OF, Oracle multi-table INSERT, …) and tracking a moving API; delegating keeps this class at a dozen lines.

Enums

Enum

Description

Dialect

The enum Dialect.

Class JDBCParquetWriter

Package: com.manticore.jdbc.parquetwriter

public class JDBCParquetWriter

The JDBC parquet writer class.

Field Summary

Modifier and Type

Field

public static final java.util.logging.Logger

LOGGER

The constant LOGGER.

Field Detail

LOGGER

public static final java.util.logging.Logger LOGGER

The constant LOGGER.

Method Summary

Modifier and Type

Method

public static String

public static String

getImportStatement(Dialect dialect, String targetTableName, java.io.File file)

Builds the dialect specific statement importing a parquet file into an existing table.

public static String

writeFilesForQueryTables(java.io.File folder, String qryStr, java.sql.Connection conn, Dialect dialect, org.apache.parquet.hadoop.metadata.CompressionCodecName compressionCodecName)

Write all tables used in a query into parquet files and returns an INSERT statement string for importing all those files into tables of the given dialect.

public static long

write(java.io.File file, String tableName, java.sql.Connection conn)

Writes a source table into a ParquetFile using SNAPPY for compression

public static long

public static long

write(java.io.File f, String tableName, java.sql.ResultSet rs)

Writes a ResultSet into a ParquetFile using SNAPPY for compression

public static long

public static org.apache.parquet.schema.MessageType

Method Detail

writeFileForQueryResult

public static String writeFileForQueryResult(java.io.File folder, String qryStr, String targetTableName, java.sql.Connection conn, Dialect dialect, org.apache.parquet.hadoop.metadata.CompressionCodecName compressionCodecName) throws java.sql.SQLException, java.io.IOException

Writes a query into a parquet file and returns an INSERT statement string for importing this file into a table of the given dialect.

Parameters

folder — java.io.File — the folder for writing the parquet file to

qryStr — String — the query to execute

targetTableName — String — the target table name

conn — java.sql.Connection — the JDBC connection for executing the query

dialect — Dialect — the dialect for the INSERT statement

compressionCodecName — org.apache.parquet.hadoop.metadata.CompressionCodecName — the compression codec name

Returns

String — the INSERT statement text

@throws: SQLException any exception during query execution

@throws: IOException any exception while writing the file

getImportStatement

public static String getImportStatement(Dialect dialect, String targetTableName, java.io.File file)

Builds the dialect specific statement importing a parquet file into an existing table.

Parameters

dialect — Dialect — the target dialect

targetTableName — String — the target table name

file — java.io.File — the parquet file to read

Returns

String — the INSERT statement text

writeFilesForQueryTables

public static String writeFilesForQueryTables(java.io.File folder, String qryStr, java.sql.Connection conn, Dialect dialect, org.apache.parquet.hadoop.metadata.CompressionCodecName compressionCodecName) throws java.sql.SQLException, java.io.IOException, net.sf.jsqlparser.JSQLParserException

Write all tables used in a query into parquet files and returns an INSERT statement string for importing all those files into tables of the given dialect.

Parameters

folder — java.io.File — the folder for writing the parquet file to

qryStr — String — the query definition with the tables

conn — java.sql.Connection — the JDBC connection for executing the query

dialect — Dialect — the dialect for the INSERT statement

compressionCodecName — org.apache.parquet.hadoop.metadata.CompressionCodecName — the compression codec name

Returns

String — the INSERT statement text

Throws

java.sql.SQLException

java.io.IOException

net.sf.jsqlparser.JSQLParserException

@throws: SQLException any exception during query execution

@throws: IOException any exception while writing the files

@throws: JSQLParserException when the query can not be parsed

write

public static long write(java.io.File file, String tableName, java.sql.Connection conn) throws java.sql.SQLException, java.io.IOException

Writes a source table into a ParquetFile using SNAPPY for compression

Parameters

file — java.io.File — the destination File

tableName — String — the source table name

conn — java.sql.Connection — the source JDBC connection for accessing the source table

Returns

long — the tally of written rows

@throws: SQLException any exception from query execution

@throws: IOException any exception while writing the file

write

public static long write(java.io.File file, String tableName, java.sql.Connection conn, org.apache.parquet.hadoop.metadata.CompressionCodecName compressionCodecName) throws java.sql.SQLException, java.io.IOException

Writes a source table into a ParquetFile

Parameters

file — java.io.File — the destination File

tableName — String — the source table name

conn — java.sql.Connection — the source JDBC connection for accessing the source table

compressionCodecName — org.apache.parquet.hadoop.metadata.CompressionCodecName — the compression codec name

Returns

long — the tally of written rows

@throws: SQLException any exception from query execution

@throws: IOException any exception while writing the file

write

public static long write(java.io.File f, String tableName, java.sql.ResultSet rs) throws java.sql.SQLException, java.io.IOException

Writes a ResultSet into a ParquetFile using SNAPPY for compression

Parameters

f — java.io.File — the destination File

tableName — String — the destination table name

rs — java.sql.ResultSet — the ResultSet of data

Returns

long — the tally of written rows

@throws: SQLException any exception from query execution

@throws: IOException any exception while writing the file

write

public static long write(java.io.File f, String tableName, java.sql.ResultSet rs, org.apache.parquet.hadoop.metadata.CompressionCodecName compressionCodecName) throws java.sql.SQLException, java.io.IOException

Writes a ResultSet into a ParquetFile.

Parameters

f — java.io.File — the destination File

tableName — String — the destination table name

rs — java.sql.ResultSet — the ResultSet of data

compressionCodecName — org.apache.parquet.hadoop.metadata.CompressionCodecName — the compression codec name

Returns

long — the tally of written rows

@throws: SQLException any exception from query execution

@throws: IOException any exception while writing the file

getParquetSchemaFromResultSet

public static org.apache.parquet.schema.MessageType getParquetSchemaFromResultSet(String tableName, java.sql.ResultSetMetaData metadata) throws java.sql.SQLException

Derive the parquet schema from a JDBC result set.

Parameters

tableName — String — the table name

metadata — java.sql.ResultSetMetaData — the JDBC metadata

Returns

org.apache.parquet.schema.MessageType — the parquet schema from result set

@throws: SQLException any exception from query execution

Class TableNamesFinder

Package: com.manticore.jdbc.parquetwriter

public class TableNamesFinder extends net.sf.jsqlparser.util.TablesNamesFinder<Void>

Splits the tables of a statement into the one DML target table and the source tables feeding it.

The traversal itself is left entirely to TablesNamesFinder: the overrides below only record the target table on the way through and then delegate. Re-implementing the DML visitors here means missing every clause JSqlParser adds later (RETURNING, FOR PORTION OF, Oracle multi-table INSERT, …) and tracking a moving API; delegating keeps this class at a dozen lines.

Constructor Summary

Constructor

Constructor Detail

TableNamesFinder

public TableNamesFinder(String sqlStr) throws net.sf.jsqlparser.JSQLParserException

Parameters

sqlStr — String

Throws

net.sf.jsqlparser.JSQLParserException

Method Summary

Modifier and Type

Method

public String

getTargetTableName()

The table an INSERT, UPDATE, DELETE or MERGE writes into, or ``null`` for a SELECT.

public java.util.Set<String>

getSourceTableNames()

The tables the statement reads from; the returned set is a defensive copy.

public Void

public Void

public Void

public Void

Method Detail

getTargetTableName

public String getTargetTableName()

The table an INSERT, UPDATE, DELETE or MERGE writes into, or null for a SELECT.

Returns

String

getSourceTableNames

public java.util.Set<String> getSourceTableNames()

The tables the statement reads from; the returned set is a defensive copy.

visit

public Void visit(net.sf.jsqlparser.statement.insert.Insert insert, S context)

Parameters

insert — net.sf.jsqlparser.statement.insert.Insert

context — S

Returns

Void

visit

public Void visit(net.sf.jsqlparser.statement.update.Update update, S context)

Parameters

update — net.sf.jsqlparser.statement.update.Update

context — S

Returns

Void

visit

public Void visit(net.sf.jsqlparser.statement.delete.Delete delete, S context)

Parameters

delete — net.sf.jsqlparser.statement.delete.Delete

context — S

Returns

Void

visit

public Void visit(net.sf.jsqlparser.statement.merge.Merge merge, S context)

Parameters

merge — net.sf.jsqlparser.statement.merge.Merge

context — S

Returns

Void

Enum Dialect

Package: com.manticore.jdbc.parquetwriter.JDBCParquetWriter

public enum Dialect

The enum Dialect.

Enum Constants

Enum Constant

DUCKDB

Duckdb dialect.

CLICKHOUSE

Clickhouse dialect.

Enum Constant Detail

DUCKDB

public static final Dialect DUCKDB

Duckdb dialect.

CLICKHOUSE

public static final Dialect CLICKHOUSE

Clickhouse dialect.