Skip to content

Update docs on new table formats - #582

Open
kkin-here wants to merge 15 commits into
v3from
docs/custom-columns
Open

Update docs on new table formats#582
kkin-here wants to merge 15 commits into
v3from
docs/custom-columns

Conversation

@kkin-here

Copy link
Copy Markdown

No description provided.

xeus2001 and others added 15 commits May 13, 2026 08:04
Signed-off-by: Alexander Lowey-Weber <alexander.weber@here.com>
…implementation as far as possible.

Signed-off-by: Alexander Lowey-Weber <alexander.weber@here.com>
Signed-off-by: Alexander Lowey-Weber <alexander.weber@here.com>
Signed-off-by: Alexander Lowey-Weber <alexander.weber@here.com>
Signed-off-by: Alexander Lowey-Weber <alexander.weber@here.com>
Signed-off-by: Alexander Lowey-Weber <alexander.weber@here.com>
Signed-off-by: Alexander Lowey-Weber <alexander.weber@here.com>
Signed-off-by: Alexander Lowey-Weber <alexander.weber@here.com>
Root cause #1: Guid.ALL_PARTS was still 13 (expecting old uid field)
- Guid.kt — removed UID constant, changed ALL_PARTS from 13 to 12. The
Guid.fromString() was rejecting valid GUID strings because it expected
13 colon-separated parts (the old format with uid) but the new format
only has 12. This caused XyzNs.guid to silently return null, breaking 23
tests.
Root cause #2: next_tn/prev_tn/base_tn were B64 (8 bytes = txn only),
not unique per feature
- All features in the same transaction share the same txn value, so B64
next_tn was identical for all features written in one batch — making
history queries by next_tn return all features from that transaction
instead of only the intended ones.
- Fixed by changing next_tn/prev_tn/base_tn to B128 (16 bytes =
featureNumber + txn), which is unique per feature.
Files changed:
- Guid.kt — removed UID = 12, changed ALL_PARTS to 12
- PgColumnRows.kt — reads/writes prev_tn/next_tn/base_tn with B128
instead of B64
- PgWriterUpdate.kt — history next_tn set to new_row.tn (full B128)
- PgWriterUpsert.kt — history next_tn set to naksha_tn_128(...) with
action bits; prev_tn set to full head_row.tn; reads prev_tn via getB128
- PgWriterDelete.kt — tombstone next_tn set to naksha_tn_128(...);
prev_tn set to full head_row.tn; history next_tn set to tombstone.tn
- PgTable.kt — tombstone constraint changed from next_tn =
naksha_tn_64(tn) to next_tn = tn
- PgColumn.kt — KDocs updated for next_tn/prev_tn/base_tn
- ReadFeaturesByOtherTns.kt — test updated to serialize TupleNumbers as
B128 for next_tn queries

Signed-off-by: Alexander Lowey-Weber <alexander.weber@here.com>
Introduces `NakshaCollection.members` (typed user-defined columns) and
`NakshaCollection.indices` (replaces the legacy StringList opt-in list of
built-in indexes). At write time, the storage walks each feature using the
member's JsonPath (defaults to ["properties", name]), coerces the value to
the declared CustomMemberType, and stores it in a real Postgres column
namespaced with `$` (`$age`, `$price`, ...) to avoid collision with built-ins.
The value also remains in the encoded feature blob.

CustomMemberType (model-only, no SQL flavor):
  BOOLEAN, INT8/16/32/64, FLOAT32/64, STRING, BYTE_ARRAY,
  FLAT_MAP (object of primitives), TAGS (string-array expanded to flat map).

CustomIndexType: BTREE, SPATIAL, FLAT_MAP.

Schema mutability runs on UPSERT/UPDATE of an existing collection:
  - same name + same dataType -> no-op
  - same name + different dataType -> ILLEGAL_ARGUMENT (no type change)
  - new member -> ALTER TABLE ADD COLUMN on HEAD/HISTORY/DELETED/META roots
                  (nullable, no default - metadata-only on PG 11+)
  - removed member -> requires Write.force=true; ALTER TABLE DROP COLUMN
  - index identity = (name, type, on, include, unique); any diff -> drop+create

PgIndex.DEFAULT_INDICES is now always applied; the closed-enum opt-in via
`indices: StringList` is removed.

Naming:
  - Member/index names use the standard Naksha.verifyId rules (no new regex
    or MAX_LENGTH).
  - Physical PG column is `$<name>` so user names cannot collide with the
    built-in column namespace.
Signed-off-by: kkin-here <284318677+kkin-here@users.noreply.github.com>
Signed-off-by: kkin-here <284318677+kkin-here@users.noreply.github.com>
Signed-off-by: Alexander Lowey-Weber <alexander.weber@here.com>
Signed-off-by: Alexander Lowey-Weber <alexander.weber@here.com>
Signed-off-by: kkin-here <284318677+kkin-here@users.noreply.github.com>
@kkin-here
kkin-here requested a review from xeus2001 May 19, 2026 14:14
@kkin-here
kkin-here marked this pull request as ready for review May 19, 2026 14:15
xeus2001
xeus2001 previously approved these changes May 21, 2026
Base automatically changed from lib_data to v3 September 1, 2026 08:26
@xeus2001
xeus2001 dismissed their stale review September 1, 2026 08:26

The base branch was changed.

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.

2 participants