Skip to content

feat(lance): fix half-float, unsigned int, and struct type mapping#4

Open
jja725 wants to merge 16 commits into
lance-native-connectorfrom
lance-type-struct-mapping
Open

feat(lance): fix half-float, unsigned int, and struct type mapping#4
jja725 wants to merge 16 commits into
lance-native-connectorfrom
lance-type-struct-mapping

Conversation

@jja725

@jja725 jja725 commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

Ports type-mapping fixes from the Trino Lance connector to the Presto SPI Lance connector.

  • f16 → REAL: Arrow half-float (Float2Vector) now maps to REAL (was incorrectly DOUBLE); f16 values are widened to f32 to meet Presto's REAL minimum.
  • unsigned int → BIGINT: unsigned int32 (UInt4Vector) maps to BIGINT; unsigned int64 (UInt8Vector) is read without sign loss.
  • struct → ROW: Arrow Struct maps to RowType in LanceColumnHandle so nested struct columns project as ROW(...).

The shared ArrowBlockBuilder (presto-common-arrow) gains Float2/UInt4/UInt8 vector dispatch + assign methods. Bumps lance-core to 4.0.0-beta.13 for the required Arrow vector / dataset APIs.

Test plan

  • New unit tests: TestLanceArrowBlockBuilder (f16→REAL, unsigned int32/int64 reads), additions to TestLanceColumnHandle (half-float→REAL, unsigned int32→BIGINT, struct→RowType).
  • ./mvnw -o test -pl presto-lance24 tests, BUILD SUCCESS.

Based on lance-native-connector (not master) since the Lance connector work stacks on it.

🤖 Generated with Claude Code

jja725 and others added 16 commits March 26, 2026 10:37
…ctor

Add the protocol translation layer in presto_cpp to convert Java
coordinator protocol types to Velox Lance connector types, following
the Hive/Iceberg pattern.

Changes:
- Add datasetPath to Java LanceSplit so native workers can locate datasets
- Create C++ protocol types (LanceSplit, LanceTableHandle, LanceColumnHandle,
  LanceTableLayoutHandle) with JSON serialization matching Java @JsonProperty
- Create LancePrestoToVeloxConnector with toVeloxSplit, toVeloxColumnHandle,
  toVeloxTableHandle conversions
- Register Lance connector factory and PrestoToVeloxConnector behind
  PRESTO_ENABLE_LANCE cmake flag

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Wire the Lance connector into the same chevron+mustache pipeline that
hive, iceberg, tpch, and arrow_flight use. Hand-written C++ protocol
files are replaced with generated equivalents driven by:

- connector/lance/presto_protocol_lance.yml: 5 abstract subclass
  mappings (ColumnHandle, ConnectorTableHandle, ConnectorTableLayoutHandle,
  ConnectorSplit, ConnectorTransactionHandle), an UpdateFields entry to
  keep LanceTableLayoutHandle::table as shared_ptr<LanceTableHandle>,
  and 4 JavaClasses sources.
- connector/lance/presto_protocol-json-{cpp,hpp}.mustache: chevron
  templates with the lance namespace; the cpp template hardcodes the
  LanceTransactionHandle prolog because the corresponding Java class is
  an enum (mirrors the tpch pattern).
- connector/lance/special/LanceColumnHandle.hpp.inc: custom operator<()
  override since LanceColumnHandle is comparable.
- connector/lance/special/LanceTransactionHandle.{hpp,cpp}.inc: kept for
  parity with tpch's special directory layout.

Makefile gains lance entries in presto_protocol-json, presto_protocol-cpp,
and the .proto target. .gitignore picks up the new intermediate
presto_protocol_lance.json artifact.

Verified end-to-end with `make presto_protocol` — output matches the
prior hand-written types with the same field shapes and signatures, so
LancePrestoToVeloxConnector.cpp continues to compile.
Add a "Lance Connector" subsection under "Build Prestissimo" describing
the PRESTO_ENABLE_LANCE cmake flag, what it wires up
(LancePrestoToVeloxConnector + velox_lance_connector linkage), and the
upstream Velox prerequisite (facebookincubator/velox#16556).
The previous URL (lancedb.github.io/lance) 404s. Point at the upstream
repo (github.com/lancedb/lance) — the Lance file format the connector
reads, not the LanceDB database product.
The repo moved from the lancedb org to lance-format. Update the link.
…ording

The Lance protocol classes are pre-generated and checked in (per the
protocol README's "check in these generated files" rule), so saying
PRESTO_ENABLE_LANCE "compiles in" the bridge was inaccurate. The flag
really only registers the LancePrestoToVeloxConnector and links against
velox_lance_connector. Point at the existing protocol README for
regeneration instructions.

Addresses prestodb#27445 (comment)
Port type-mapping fixes from the Trino Lance connector to Presto SPI:

- Map Arrow f16 (Float2Vector) to REAL instead of DOUBLE, widening f16
  reads to f32 to meet Presto's REAL minimum (was incorrectly DOUBLE).
- Map unsigned int32 (UInt4Vector) to BIGINT and read unsigned int64
  (UInt8Vector) without sign loss.
- Map Arrow Struct to RowType in LanceColumnHandle so nested struct
  columns are projected as ROW(...).

ArrowBlockBuilder (shared presto-common-arrow) gains Float2/UInt4/UInt8
vector dispatch + assign methods. Bumps lance-core to 4.0.0-beta.13 for
the required Arrow vector and dataset APIs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant