GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |
GeezerVison is showing github.com — Bump mongo-java-driver from 3.12.4 to 3.12.10 by dependabot[bot] · Pull Request #4 · ArcadeData/arcadedb Conversation
|
|
@dependabot rebase |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
81de53e to
8786b96
Compare
Bumps [mongo-java-driver](https://github.com/mongodb/mongo-java-driver) from 3.12.4 to 3.12.10. - [Release notes](https://github.com/mongodb/mongo-java-driver/releases) - [Commits](mongodb/mongo-java-driver@r3.12.4...r3.12.10) --- updated-dependencies: - dependency-name: org.mongodb:mongo-java-driver dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]>
8786b96 to
44f17ac
Compare
…ed with the live records (#12487) Fixes #10614 ## What was wrong A Cypher label write cannot change a vertex's type in place: `LabelReplacements.replace` writes a new vertex under the new type, re-creates every incident edge under new RIDs and deletes the originals. The write steps redirected the row they were writing, and each later row before it was written, but never a row that had already been written. In the reporter's query, row 1 (`n1 = 13`) removes nothing and is buffered by `REMOVE`; row 2 (`n1 = 27`) then removes `l9` from 27, which rewrites 27 and both relationships and deletes the originals (one of them `#4:0`). Row 1 still held the deleted 27 and the deleted `rt8` edge in its path, and was answered with them: Bolt failed in `BoltStructureMapper.toPath` with `Record #4:0 not found`, HTTP answered RIDs of records that no longer exist. ## Fix - `SetStep`, `RemoveStep` and `MergeStep` redirect each row when they serve it, as `ForeachStep` already does (#11764), so a row written before a later row of the same batch relabelled one of its records leaves the step with the live records. The clauses after the write then read the live graph (a node a later row relabelled no longer reports the label, as Neo4j answers). - The drain of a write statement (`CypherExecutionPlan.executeStreaming`, and `profile()`) redirects every row it collected before ending the statement (`LabelReplacements.redirectRows`), so a row that waited downstream in a barrier (an `ORDER BY`, a `DISTINCT`, a later batch) when the write ran is answered with the live records too. - `LabelReplacements.redirect` also redirects the row's element: a `RETURN` of a single node carries it as the element, which is what the HTTP JSON is built from. - `RETURN DISTINCT` and `WITH DISTINCT` key a replacement record by the RID its replacement chain started from (`LabelReplacements.distinctKey`, also inside lists, maps and paths), so a row projected before a later row's write (holding the original) and one projected after it (holding the replacement) are one row, as Neo4j, where a node keeps its identity, answers. The collapse happens in the DISTINCT step itself, so `SKIP` and `LIMIT` apply to the right rows. - The branches of a write `UNION` share one map of label replacements (they used to have one each), so a row of an earlier branch follows a later branch's label write, and `UNION` (not `ALL`) keys rows the same way as `DISTINCT`. A statement with no label write pays one map check per row served and one per statement. ## Tests - `CypherLabelWriteRedirectsEmittedRowsIssue10614Test` (engine): the reporter's query, the same through `SET`, a later clause reading an earlier row, a row buffered in an `ORDER BY` across batches (also through the element and the JSON), `RETURN DISTINCT` (and `DISTINCT *`, `SKIP`, `LIMIT`, `WITH DISTINCT`, lists and paths) across batches, write `UNION` / `UNION ALL` across branches, and `PROFILE`. - `Issue10614BoltPathAfterLabelRemovalIT` (bolt): the reporter's query over the wire, both rows with their paths. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed Cypher write queries so returned nodes, relationships, and paths reflect changes made during query execution, including label and property updates. * Improved consistency for results across batches and in queries using `DISTINCT`, `UNION`, `WITH`, or profiling. Returned paths and connected records now remain valid after changes. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
…ting by it deletes that edge only (#12145) Fixes #12132. ### Problem Every lightweight edge of a type answered the same `elementId()`, the record-less marker `#<type bucket>:-1` that the edge lists store. The relationship element-id filter is a per-row string compare, so with an id read from ONE edge, `MATCH ()-[r:L]->() WHERE elementId(r) = $id DELETE r` deleted EVERY lightweight edge of the type. Bolt put the same string in `Relationship.element_id`, so a driver that sent it back hit the same delete. SQL `SELECT DISTINCT(@this) FROM L` also collapsed all the lightweight edges into one row. ### Semantics chosen A lightweight edge gets an element id that names it, built from what its `LightEdgeRID` already carries: ``` #<type bucket>:-1/<out RID>/<in RID> e.g. #7:-1/#1:0/#4:0 #<type bucket>:-1/<out RID>/<in RID>/<n> the n-th (n >= 1) parallel twin of the same (type, out, in) ``` Why this shape, and not refusing (`null`) the way `id()` does since #9573: - openCypher / Neo4j: `elementId()` identifies one relationship and is meant to be handed back. A `null` would make the delete safe but would break every application that reads relationship ids. Lightweight edges have no properties, so endpoints plus the twin occurrence are their whole identity. That is the identity the engine already uses for `=`, `DISTINCT` and relationship uniqueness (`LightEdgeRID.isSameEdge` / `distinctKey`, #9573, #10008). - It is deliberately NOT a RID (`RID.is()` is false for it). No RID seek and no `id()`/RID-string coercion in `ComparisonExpression` can take it for a record address. The old `#7:-1` value now matches no edge at all, instead of all of them. - It is the same from either end. The out and in lists number twins alike (tested from the OUT side, the IN side and undirected). - Twins: the occurrence is resolved through the iteration's `LightEdgeCensus`, so a list is walked about twice per iteration, not once per edge. After one twin is deleted, the occurrences renumber. Which twin a stale id names can therefore shift, but twins carry nothing to tell them apart, and deleting by either twin's id removes exactly one (tested for both twins). - `id()` stays `null` (#9573): a lightweight edge has no position to encode in the numeric id. ### Changes - `LightEdgeRID.toElementId()`: the id above. - `ElementIdFunction`: answers `ElementIdFunction.of(rid)`, the RID string for records and `toElementId()` for a lightweight edge. - `BoltStructureMapper.toRelationship` / `toUnboundRelationship`: use the same `ElementIdFunction.of`, so the Bolt `element_id` and `elementId(r)` agree. Mapping a lightweight edge also threw before (`Cannot encode RID #4:-1 as a numeric id()`), so no Bolt query could return one. A lightweight relationship now gets a negative numeric id, a 64-bit FNV-1a hash of its element id. No record id is negative, so the two can never collide, and `id(r)` stays null, so no `WHERE id(r) = ...` can resolve to it. - `DistinctExecutionStep` (SQL `DISTINCT`): a row whose element identity determines the output but has no record address (the RID fast path refuses `position < 0`) was keyed by its properties alone, and a lightweight edge has none. It is now keyed by its identity too, with twins told apart by `LightEdgeRID.distinctKey()`, as in openCypher. ### Tests - `CypherLightEdgeTest.Issue12132LightEdgeElementId` (engine; all red on `main` except the side-independence check): - three lightweight edges have three distinct ids, none parses as a RID, and record-backed edges still answer their RID - the id is the same read from the OUT side, the IN side and undirected - deleting by the id of one edge, in a second statement or in the same statement through `WITH`, deletes only that edge; the old `#bucket:-1` value deletes nothing - parallel twins have distinct ids, the same from both ends; deleting by either twin's id leaves the other - SQL `SELECT DISTINCT(@this) FROM L` and `SELECT DISTINCT @this FROM L` return 3 rows - `Issue12132LightEdgeElementIdTest` (bolt): the Bolt relationship and unbound-relationship element ids equal `elementId(r)` and differ per edge; the numeric ids are negative and differ per edge (on `main` the mapping throws). Ran: `CypherLightEdgeTest` (all nested), `LightEdgeRIDOccurrenceTest`, `LightEdgeCensusTest`, `CollectDistinctTest`, `CypherExplainTraditionalPlanTest`, `CypherMissingFunctionsTest`, `OpenCypherCollectUnwindTest`, `OpenCypherFunctionTest`, `OpenCypherScalarFunctionsComprehensiveTest`, `DistinctWithGroupByUnwindExpandTest`, `DistinctExecutionStepTest`, `SelectStatementExecutionTest`, `LightweightEdgeTypeTest`, `LightweightEdgeScanAndWriteTest`, `LightEdgeRegressionTest` (engine); `Issue12132LightEdgeElementIdTest`, `Bolt4998PathMappingTest`, `BoltStructureTest` (bolt). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Lightweight relationships now have distinct, stable element IDs, including when multiple relationships connect the same vertices. * Using an element ID to delete a lightweight relationship now removes only the matching relationship. * Queries and returned paths now distinguish parallel lightweight relationships correctly, including when applying `DISTINCT` or reading relationships from either direction. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: lvca <[email protected]>
…oes (#11967) Fixes #11958. ### Problem A Postgres-wire json column holding a record (`@this`, a Cypher node) or a map (`properties(n)`, a map literal) was rendered by `record.toJSON(true)` or `new JSONObject(map)`. Temporals came out as epoch numbers: a DATE as epoch days in a record and epoch milliseconds in a map, and a map dropped the zone of a ZONED_DATETIME and the sub-millisecond digits of a DATETIME_NANOS. HTTP sends the same row as formatted text. ### Change - `PostgresType` renders a record, a result row, a map or a path through `JsonSerializer`, the serializer the HTTP API uses, wherever a json column carries one: the scalar column, an element of a json column holding an array (a path included, e.g. `collect(p)`), and an element of a `text[]` or `json[]` array in text and binary format. Vertex edge counts are left out, as `toJSON(true)` left them out. - The date patterns come from the database the value belongs to: the record's, or the row's (`Result.getDatabase()`) when the row is not an element. A value no database owns (a map literal, a row built without one) uses the configured default patterns. - One `JsonSerializer` instance serves every connection (`PostgresType.JSON_DOCUMENT_SERIALIZER`). It is configured once in the static initializer and never changed, and a serialization keeps no state in the serializer (date patterns and type hints live in locals of each call), the same pattern as gRPC's shared `FAST`/`SAFE` serializers. No per-value allocation of a serializer on the row path. - A record that is not a document (an edge segment, a stripe directory, the payload of an EXTERNAL property) keeps its own `toJSON(true)`: `JsonSerializer` has no form for those and would hand the record back, so the column would carry its `toString()`. `Issue11958JsonDocumentShapesTest.aRecordThatIsNotADocumentKeepsItsOwnJson` pins it. - `JsonSerializer` gets a public `serializeValue(Database, Object)` that delegates to the existing private `serializeValue(database, value, null)`. The schema pattern lookups now go through two helpers that fall back to `GlobalConfiguration.DATE_FORMAT` / `DATE_TIME_FORMAT` when the database is null. Every HTTP call site passes a database, so their output is unchanged; `Issue11958SerializeValueTest.httpRowRenderingIsUnchanged` pins the HTTP rendering of these values. ### Behaviour change for clients (release notes) This changes what a Postgres client receives in a json column. Scalar temporal columns (DATE, TIMESTAMP OIDs) are unchanged. - **Temporals inside json documents are text, not epoch numbers.** A client that read a DATE or DATETIME inside a json column as a number (epoch days or epoch milliseconds) must parse the formatted text instead, the same text and the same schema `dateFormat` / `dateTimeFormat` the HTTP API sends. - **Paths** (`MATCH p = ... RETURN p`) keep the `{_type, nodes, relationships, length}` object with the same members in the same order. Each node and relationship gains the record attributes the HTTP API sends with it: `@rid`, `@type`, `@cat`, plus `@in` / `@out` on a relationship. `path.toMap()` wrote each record with `toJSON(false)`, which left them out. Non-temporal property values are the same. Measured in `aPathKeepsTheShapeOfItsMapAndGainsTheRecordAttributes`: - before: `{"_type":"path","nodes":[{"name":"a","n":7,"da":19782,"dt":1709212455123,"dtn":"2024-02-29 13:14:15.123456789",...}],"relationships":[{"da":19782,"w":2}],"length":1}` - after: `{"_type":"path","nodes":[{"@Rid":"#1:0","@type":"T11958","name":"a","n":7,"da":"2024-02-29","dt":"2024-02-29 13:14:15.123","dtn":"2024-02-29 13:14:15.123456789",...,"@cat":"v"}],"relationships":[{"@Rid":"#4:0","@type":"E11958","da":"2024-02-29","w":2,"@cat":"e","@in":"#1:1","@out":"#1:0"}],"length":1}` - **Rows that are not elements** (a projection such as `SELECT da AS d, name FROM T` yields one) keep the members and the order of `result.toJSON()`; only the temporals change. Measured in `aRowThatIsNotAnElementKeepsTheShapeOfItsJson`: - before: `{"name":"a","n":7,"da":1709164800000,"dt":1709212455123,"dtn":1709212455123,"nested":{"da":1709164800000}}` - after: `{"name":"a","n":7,"da":"2024-02-29","dt":"2024-02-29 13:14:15.123","dtn":"2024-02-29 13:14:15.123456789","nested":{"da":"2024-02-29"}}` - **DECIMAL still differs from HTTP.** A DECIMAL in those documents is unchanged: a JSON number with its exact digits (`12345678901234567890.123456789`), where HTTP sends a string. ### Measured (E2E, psycopg 3.3.9, container with this branch's engine and postgresw jars) `SELECT @this AS rec, {'da': da, 'dt': dt, 'dtn': dtn, 'zdt': zdt} AS m FROM T` and `{cypher}MATCH (n:T) RETURN n, properties(n) AS props`: | property | before, record | before, map | after, record and map (same as HTTP) | |---|---|---|---| | DATE | `19782` | `1709164800000` | `"2024-02-29"` | | DATETIME | `1709212455123` | `1709212455123` | `"2024-02-29 13:14:15.123"` | | DATETIME_NANOS | `"2024-02-29 13:14:15.123456789"` | `1709212455123` | `"2024-02-29 13:14:15.123456789"` | | ZONED_DATETIME | `"2024-03-10T03:30-04:00[America/New_York]"` | `1710055800000` | `"2024-03-10T03:30-04:00[America/New_York]"` | This E2E table was measured on the first commit; the follow-up commit's paths are covered by the tests below, not by a second psycopg run. ### Tests - `Issue11958JsonColumnTemporalsIT` (pgjdbc): a record and a map in SQL and Cypher (fails on main: DATE `19782` vs `"2024-02-29"`); a Cypher path (`MATCH p = ... RETURN p`); Cypher lists of nodes, maps and paths (`collect(n)`, `collect(properties(n))`, `collect(p)`); a map inside a `text[]` (`SELECT ['text', {...}]`); the rows of a subquery (`SELECT (SELECT da, dt, dtn, zdt FROM T) AS rows`). - `Issue11958JsonDocumentShapesTest` (postgresw, embedded): a json column holding a list of records, maps, nested lists and paths; a json document inside a `text[]` literal and inside binary `text[]` and `json[]` arrays; path and non-element row shapes compared with `path.toMap()` and `result.toJSON()`; a non-element query row rendered with its database's custom `dateFormat`; the non-document record branch. - `Issue11958SerializeValueTest` (engine): pins the HTTP row rendering and checks `serializeValue` matches it, with and without a database. - Run on the latest commit: `mvn -o -pl postgresw -am verify -DskipITs=false -Dtest='com/arcadedb/postgres/**/*Test,Issue11958SerializeValueTest' -Dit.test='com/arcadedb/postgres/**/*IT'`: postgresw unit 1001 run, ITs 624 run, engine 2 run; 0 failures, 0 errors, 0 skipped. ### Overlap with #11920 #11920 (#11838) also edits `PostgresType.java`, in the Bind parameter decoding (`deserializeText` / `deserializeBinary`, UUID). This PR touches only the json rendering of result values (`toText`, `arrayElementToText`, the json array helpers), so the two do not change the same code. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed JSON serialization of date and date-time values when records are returned through PostgreSQL, including values nested in maps, lists, arrays, and paths. * Temporal values now retain their expected formatting in database-backed and detached records, including date precision and time zones. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: lvca <[email protected]>
…crosses record kinds (#12063) Fixes #12028 Fixes #12029 Both issues are missing refusals in the same place: the checks a super type link is asked before anything changes (`LocalDocumentType.checkCanAddSuperType`, which `ALTER TYPE ... SUPERTYPE +`, `Schema` API `addSuperType` and `TypeBuilder` on an existing type all go through). So they are fixed together, in one PR. ### What changes - **Cycle (#12028)**: `checkCanAddSuperType` refuses, first and for every linkage, a super type that is the type itself or already one of its sub types (`DocumentType.isSubTypeOf`, which only walks up the super type lists and so ends). The statement is refused with a `SchemaException` (HTTP 400) before the link is made, so nothing is left in memory. It used to link, overflow the stack in the post-link steps (a `StackOverflowError` is not the `RuntimeException` the unlink guard catches), and keep the cycle. - **Load**: a `schema.json` that already holds a cycle (the next schema save after the old 500 could write one) still opens. The inheritance restore leaves out the link that would close the cycle and logs a warning naming it. Before, every polymorphic walk over the loaded cycle overflowed. - **Record kind (#12029)**: a new linkage refuses a graph super type of another kind (a document or edge type under a vertex type, a vertex or document type under an edge type), in `checkCanAddSuperType` for ALTER and in `TypeBuilder` for a new type (`CREATE ... TYPE ... EXTENDS` and the Java builder). A DOCUMENT super type stays legal for a vertex or an edge type: existing schemas use it to share properties (`SchemaTest.dropNonExistentIndexThenCreateProperty` has `CREATE VERTEX TYPE ... EXTENDS <document type>`), and a vertex or an edge is a document, so a scan of the super type reads nothing it cannot hold. Linkages that already hold (schema load, re-attachment after `DROP TYPE`) are not asked, so a database written before the check still opens. ### Tests `SuperTypeAdmissionTest` (new, engine, one nested class per issue): - cycle refused through SQL (direct and two levels down), the Java API and the type builder; schema unchanged, `SELECT FROM A` and `CREATE PROPERTY A.y` work after; - a hand-edited `schema.json` holding a cycle opens, keeps two of the three links, scans and saves; - ALTER refuses document under vertex, vertex under edge, edge under vertex; same kind, and vertex or edge under document, stay legal; Cypher `MATCH (v:V)` answers; - `CREATE DOCUMENT TYPE ... EXTENDS <vertex>`, `CREATE EDGE TYPE ... EXTENDS <vertex>`, `CREATE VERTEX TYPE ... EXTENDS <edge>` and `buildDocumentType().withSuperType(<vertex>)` refused, no type created; `CREATE VERTEX TYPE ... EXTENDS <document>` and an edge type built over a document type stay legal; - a hand-edited `schema.json` with a cross-kind link still opens. ### Results Engine tests (Docker, maven:3.9-eclipse-temurin-21): - failing-first with `engine/src/main` from origin/main: `SuperTypeAdmissionTest` 6 run, 5 fail (4 failures, 1 error: `aSchemaFileWithACycleStillOpens` StackOverflowError). - `-Dtest='com/arcadedb/schema/**/*Test,SuperTypeAdmissionTest' -DexcludedGroups=slow`: 1812 tests, 0 failures, 0 errors, 0 skipped. - whole engine module, `-pl engine test -DexcludedGroups=slow`: 27969 tests, 2 failures, 3 errors, 22 skipped. None is from this change: `ParallelSafeExpressionsStateTest` (1 failure) and `CypherCallInTransactionsOnErrorIssue11595Test` (3 errors) fail the same way with `engine/src/main` from origin/main; `ReplicatedApplyPublicationTest` (1 failure) passed on origin/main and passed again alone on this branch (timing-dependent). - server module, `-pl server -am test -Dtest='com/arcadedb/server/**/*Http*Test,com/arcadedb/server/**/*Command*Test,com/arcadedb/server/**/*Schema*Test'`: 263 tests, 0 failures, 0 errors, 0 skipped. - server ITs that send DDL and assert HTTP statuses (28 classes, among them `HTTPDocumentIT`, `HTTPGraphIT`, `RemoteDatabaseIT`, `SchemaMutationAuthorizationIT`, `FacetsSubtypeAclIT`, `TestLinkedPropertiesSchemaReloadIT`): 187 tests, 0 failures, 0 errors, 0 skipped. End to end, HTTP against a server built from main (`s12028` repro): Server with the main jars (a7304ab): version 200 == cycle: A <- B <- C, then ALTER TYPE A SUPERTYPE +C 200 CREATE VERTEX TYPE A -> [{"operation": "create vertex type", "typeName": "A", "created": true}] 200 CREATE VERTEX TYPE B EXTENDS A -> [{"operation": "create vertex type", "typeName": "B", "created": true}] 200 CREATE VERTEX TYPE C EXTENDS B -> [{"operation": "create vertex type", "typeName": "C", "created": true}] 200 INSERT INTO C SET x = 1 -> [{"@Rid": "#7:0", "@type": "C", "@cat": "v", "x": 1}] 500 ALTER TYPE A SUPERTYPE +C -> "DatabaseOperationException: Error during write lock -> StackOverflowError" 200 SELECT name, parentTypes FROM schema:types ORDER BY name -> [{"name": "A", "parentTypes": ["C"]}, {"name": "B", "parentTypes": ["A"]}, {"name": "C", "parentTypes": ["B"]}] 200 SELECT count(*) FROM A -> [{"count(*)": 1}] 500 SELECT FROM A -> "StackOverflowError: java.lang.StackOverflowError" 500 CREATE PROPERTY A.y INTEGER -> "DatabaseOperationException: Error during write lock -> StackOverflowError" 400 INSERT INTO A SET x = 2 -> "CommandSQLParsingException: The statement is nested or chained too deeply to be executed (the thread stack overflowed while building the plan) -> StackOverflowError" == cross kind: document type D gets vertex super type V; vertex type W gets edge super type E 200 CREATE VERTEX TYPE V -> [{"operation": "create vertex type", "typeName": "V", "created": true}] 200 CREATE DOCUMENT TYPE D -> [{"operation": "create document type", "typeName": "D", "created": true}] 200 CREATE EDGE TYPE E -> [{"operation": "create edge type", "typeName": "E", "created": true}] 200 CREATE VERTEX TYPE W -> [{"operation": "create vertex type", "typeName": "W", "created": true}] 200 INSERT INTO V SET n = 1 -> [{"@Rid": "#1:0", "@type": "V", "@cat": "v", "n": 1}] 200 INSERT INTO D SET n = 2 -> [{"@Rid": "#4:0", "@type": "D", "@cat": "d", "n": 2}] 200 INSERT INTO W SET n = 3 -> [{"@Rid": "#6:0", "@type": "W", "@cat": "v", "n": 3}] 200 ALTER TYPE D SUPERTYPE +V -> [{"supertype": ["V"], "operation": "ALTER TYPE", "typeName": "D", "result": "OK"}] 200 ALTER TYPE W SUPERTYPE +E -> [{"supertype": ["E"], "operation": "ALTER TYPE", "typeName": "W", "result": "OK"}] 200 SELECT name, type, parentTypes FROM schema:types ORDER BY name -> [{"name": "D", "type": "document", "parentTypes": ["V"]}, {"name": "E", "type": "edge", "parentTypes": []}, {"name": "V", "type": "vertex", "parentTypes": []}, {"name": "W", "type": "vertex", "parentTypes": ["E"]}] 200 SELECT @Rid, @type, @cat, n FROM V -> [{"@Rid": "#1:0", "@type": "V", "@cat": "v", "n": 1}, {"@Rid": "#4:0", "@type": "D", "@cat": "d", "n": 2}] 500 MATCH (v:V) RETURN v.n -> "ClassCastException: Cannot cast the document #4:0 to a vertex" 200 SELECT @Rid, @type, @cat, n FROM E -> [{"@Rid": "#6:0", "@type": "W", "@cat": "v", "n": 3}] 200 MATCH ()-[e:E]->() RETURN count(e) -> [{"count(e)": 0}] Same server, engine jar built from this branch: version 200 == cycle: A <- B <- C, then ALTER TYPE A SUPERTYPE +C 200 CREATE VERTEX TYPE A -> [{"operation": "create vertex type", "typeName": "A", "created": true}] 200 CREATE VERTEX TYPE B EXTENDS A -> [{"operation": "create vertex type", "typeName": "B", "created": true}] 200 CREATE VERTEX TYPE C EXTENDS B -> [{"operation": "create vertex type", "typeName": "C", "created": true}] 200 INSERT INTO C SET x = 1 -> [{"@Rid": "#7:0", "@type": "C", "@cat": "v", "x": 1}] 400 ALTER TYPE A SUPERTYPE +C -> "SchemaException: Cannot make type 'A' a sub type of 'C': 'C' is already a sub type of 'A', and a type hierarchy cannot have a cycle" 200 SELECT name, parentTypes FROM schema:types ORDER BY name -> [{"name": "A", "parentTypes": []}, {"name": "B", "parentTypes": ["A"]}, {"name": "C", "parentTypes": ["B"]}] 200 SELECT count(*) FROM A -> [{"count(*)": 1}] 200 SELECT FROM A -> [{"@Rid": "#7:0", "@type": "C", "@cat": "v", "x": 1}] 200 CREATE PROPERTY A.y INTEGER -> [{"operation": "create property", "typeName": "A", "propertyName": "y", "created": true}] 200 INSERT INTO A SET x = 2 -> [{"@Rid": "#1:0", "@type": "A", "@cat": "v", "x": 2}] == cross kind: document type D gets vertex super type V; vertex type W gets edge super type E 200 CREATE VERTEX TYPE V -> [{"operation": "create vertex type", "typeName": "V", "created": true}] 200 CREATE DOCUMENT TYPE D -> [{"operation": "create document type", "typeName": "D", "created": true}] 200 CREATE EDGE TYPE E -> [{"operation": "create edge type", "typeName": "E", "created": true}] 200 CREATE VERTEX TYPE W -> [{"operation": "create vertex type", "typeName": "W", "created": true}] 200 INSERT INTO V SET n = 1 -> [{"@Rid": "#1:0", "@type": "V", "@cat": "v", "n": 1}] 200 INSERT INTO D SET n = 2 -> [{"@Rid": "#4:0", "@type": "D", "@cat": "d", "n": 2}] 200 INSERT INTO W SET n = 3 -> [{"@Rid": "#6:0", "@type": "W", "@cat": "v", "n": 3}] 400 ALTER TYPE D SUPERTYPE +V -> "SchemaException: Cannot make the document type 'D' a sub type of the vertex type 'V': a type can only extend a document type or a type of its own kind" 400 ALTER TYPE W SUPERTYPE +E -> "SchemaException: Cannot make the vertex type 'W' a sub type of the edge type 'E': a type can only extend a document type or a type of its own kind" 200 SELECT name, type, parentTypes FROM schema:types ORDER BY name -> [{"name": "D", "type": "document", "parentTypes": []}, {"name": "E", "type": "edge", "parentTypes": []}, {"name": "V", "type": "vertex", "parentTypes": []}, {"name": "W", "type": "vertex", "parentTypes": []}] 200 SELECT @Rid, @type, @cat, n FROM V -> [{"@Rid": "#1:0", "@type": "V", "@cat": "v", "n": 1}] 200 MATCH (v:V) RETURN v.n -> [{"v.n": 1}] 200 SELECT @Rid, @type, @cat, n FROM E -> [] 200 MATCH ()-[e:E]->() RETURN count(e) -> [{"count(e)": 0}] Overlap note: separate PRs for #12031, #12032, #12035, #12036, #12038 and #12039 are being prepared in the same area (`LocalDocumentType`, `LocalSchema`, `ExistingRecordsCheck`, the ALTER/CREATE TYPE statements). Textual merge conflicts with them are possible; the changes are meant to be independent. This PR and the one for #12030 both add a step at the end of `LocalDocumentType.checkCanAddSuperType`, so the second to merge needs a small rebase. ### Merge note: #12067 This PR conflicts textually with #12067 in `LocalDocumentType.java`, around line 3496. Both add private methods directly after `checkCanAddSuperType`. This PR adds `checkNoCycle`, `checkSameRecordKind` and `recordKindName`; #12067 adds `checkStoredRecordsMeetInheritedProperties`. To resolve it, keep both blocks. One ordering rule applies after the merge. #12067's stored-record scan (`checkStoredRecordsMeetInheritedProperties`, which walks `superType.getPolymorphicProperties()`) has to stay after the `checkNoCycle` call that this PR puts at the head of `checkCanAddSuperType`. Run before it, that walk could follow a cycle before the cycle check refuses it. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Schema inheritance now rejects cycles and incompatible record types, preventing invalid parent-child relationships from being created through SQL commands or builders. * Existing schema files with cyclic or incompatible inheritance links can still load; invalid links are skipped. * Type removal now refuses to proceed when reattaching child types would create an incompatible relationship. Same-kind inheritance and document supertypes for graph types remain supported. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: lvca <[email protected]>
…ut of a view's columns (#12231) Fixes #12229. ### Problem A Graph Analytical View keeps a property out of its columns when its types declare it with different column types, but the exclusion did not hold: 1. The collector removed the name on the conflict and the next type declaring it added it again: `A.p INTEGER`, `B.p DOUBLE`, `C.p INTEGER` gave an `INT` column for `p` (the same for edge properties: `R.w INTEGER`, `S.w DOUBLE`, `T.w INTEGER` gave an `INT` edge column for `w`). 2. When the conflict left no declared vertex property, the build fell back to sampling records for schemaless properties, and the first sampled value created a column for the conflicting name: `A.p INTEGER`, `B.p DOUBLE` gave an `INT` column. In both vertex cases the view served `p` for the `INTEGER` types from the column and held nothing for the `DOUBLE` vertices (their values do not round-trip through `INT`, so `fillProperties` skips them). ### Change `CSRBuilder`: - One collector, `declaredColumnTypes(typeNames, included, conflicting, ...)`, replaces `collectSchemaProperties` and `collectEdgeSchemaProperties`, which were the same loop with a different filter and log text. It records every name that conflicted in `conflicting` and skips that name for every later type. - The vertex path keeps that set for the build, and `sampleProperties` skips the names in it. ### Tests New `GavPropertyTypeConflictTest`: | test | `engine/src/main` from `origin/main` | this branch | |---|---|---| | `aVertexPropertyConflictStaysAcrossALaterType` (A INTEGER, B DOUBLE, C INTEGER) | fails: `{#7:0=4, #4:0=null, #4:1=null, #1:0=1}` served from the view | passes, no vertex served `p` from a column | | `aVertexPropertyConflictIsNotSampledBack` (A INTEGER, B DOUBLE) | fails: `{#4:0=null, #4:1=null, #1:0=1}` | passes | | `anEdgePropertyConflictStaysAcrossALaterType` (R INTEGER, S DOUBLE, T INTEGER) | fails: the view has an edge column | passes | `com/arcadedb/graph/olap/**/*Test` and `WeightedPathTest` (excluding `slow`): 743 tests, all pass. ### Overlap with #12194 #12194 (open) changes `collectEdgeSchemaProperties` the same way for the edge case (commit eab5491, from a review comment). Whichever of the two merges second needs that method resolved to the shared `declaredColumnTypes` of this PR. --------- Co-authored-by: lvca <[email protected]>
… is a type error, as in Neo4j (#13339) Fixes #12622 ## What was wrong In openCypher, `+` with a STRING on one side refused a Map and a Point (#12397). Every other operand that was not a string fell through to `leftValue.toString() + rightValue.toString()`. So a node, a relationship, a path or a plain document came back as the internal record string: - `MATCH (a:Person {name:'Alice'}) RETURN 'x:' + a` returned `x:#1:0[name=Alice]` - `MATCH ()-[r:Knows]->() RETURN 'r:' + r` returned `r:V(#1:0)->[E#4:0]->V(#1:1)` - `MATCH p=(a)-->() RETURN 'p:' + p` returned `p:(#1:0)-[#4:0]->(#1:1)` Neo4j refuses all three: `Type mismatch: expected Float, Integer, String or List<T> but was Node` (also `Relationship` and `Path`). ## Fix `ArithmeticExpression.apply()` handles `+` for the AST path, `ExpressionEvaluator` and `ConstantFolder`. In its string-concatenation branch, a new helper, `notConcatenableTypeName()`, returns the Neo4j type name of an operand that cannot be concatenated: - `Node` for a Vertex - `Relationship` for an Edge - `Path` for a path value (`CypherFunctionHelper.isPathValue`) - `Point` / `Map` for a map, as before - `Map` for any other document The branch throws the same `TypeMismatchException` #12397 introduced, for either operand order. Strings, numbers, booleans, temporal values and RIDs still concatenate. A variable-length relationship binds a list, and `+` still appends to it. ## Tests - New `CypherStringConcatGraphEntityIssue12622Test` (11 cases): node, relationship and path on either side of `+`, a node passed through `WITH`, a `shortestPath` path, and a document passed as a parameter. Controls cover strings, numbers, booleans, a date, a RID and list append. 9 cases failed before the fix and all 11 pass now. - `mvn -o -pl engine -am test -Dtest=com/arcadedb/query/opencypher/*Test,com/arcadedb/query/opencypher/**/*Test,com/arcadedb/function/**/*Test,com/arcadedb/query/sql/**/*Arith*Test -DexcludedGroups=benchmark,slow,vector`: 12173 tests, 0 failures. - openCypher TCK (`-Dsurefire.includes=**/*Suite.java`): 3897 scenarios, 0 failures. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * String concatenation with nodes, relationships, paths, maps, or points now returns a type mismatch error instead of converting the value to a string. * Error messages identify the incompatible operand’s type. Concatenation with supported scalar values and properties continues to work as expected. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.