feat(jdbc): JdbcExporter, matching the CSV and Parquet exporters

Đang mở
#567 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java, sql
Lĩnh vực
database

Hướng nghiên cứu

Start by comparing the existing JdbcImporter and JdbcImportOptions with the CSV and Parquet exporter APIs to locate the JDBC module’s conventions. Then review the import type mapping and exporter progress listener patterns before defining the export API and binder behavior. Done means exporting rows into a caller-provided table in batches with validity-aware nulls, transaction rollback on failure, restored auto-commit, and opt-in DDL support.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

vortex-jdbc only has JdbcImporter/JdbcImportOptions; csv and parquet each have an importer and an exporter. Add JdbcExporter + JdbcExportOptions for symmetry: read a Vortex file and move its rows into a table in a JDBC database over a caller-supplied Connection.

API sketch

JdbcExportOptions opts = JdbcExportOptions.defaults()
        .withBatchSize(5_000)
        .withBinder(JdbcBinder.standard()
                .with(DType.Extension.class, (ps, i, value) -> ps.setObject(i, value)));

JdbcExporter.export(vortexPath, connection, "ohlc", opts);
  • Options are a final class with a private constructor, defaults() and withXxx copies, as everywhere else. The target table is a required argument of export, not an option (confirm that CsvExporter/ParquetExporter take their target the same way).
  • Binder (callback): a small functional interface that sets one value on a PreparedStatement. JdbcBinder.standard() covers primitives, strings, decimals, booleans and dates. A user overrides only the types their database needs special handling for (Postgres arrays, setObject for timestamps).
  • DDL helper, not automatic: a DType to SQL type function plus createTableSql(name, dtype) returns a CREATE TABLE string. The exporter never creates or alters a table on its own; creation is opt-in.

Behavior

  • Appends to an existing table with INSERT INTO t (cols...) VALUES (?, ...) through a PreparedStatement. Nulls follow the validity mask.
  • One transaction for the whole export: remember the connection's auto-commit setting, setAutoCommit(false), addBatch() per row, executeBatch() every batchSize rows, commit() at the end, rollback() and rethrow on failure, and restore auto-commit in a finally. The connection belongs to the caller. A failed export leaves nothing behind.
  • ProgressListener, as in the other exporters.

Open design questions

  • Reverse type mapping DType to SQL type (the inverse of SqlTypeToDType); it varies by database.
  • Create-if-missing vs truncate vs fail-if-exists: all opt-in, append is the default.
  • A withCommitEvery(n) option for very large exports, if a long-lived transaction proves a problem. Not in the first cut.

Not needed for the jdbc:vortex: driver work (#566). No demand yet, so this waits until someone needs it.

Ngôn ngữ chính
Java
Star
3
Fork
2
Merge trung bình
14 giờ 59 phút
Pull request đã merge (30 ngày)
137

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của dfa1/vortex-java

Tất cả issue của dfa1/vortex-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.