Skip to content

Commit 45ef19d

Browse files
committed
feat(schema): manage Oracle-family triggers in existing object workflows
1 parent 8cdfb89 commit 45ef19d

171 files changed

Lines changed: 14754 additions & 443 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎agents/common/src/main/java/com/dbx/agent/DatabaseAgent.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ default List<ObjectInfo> listObjects(String schema, MetadataListConstraints cons
8686
return MetadataListConstraints.orNone(constraints).filterObjects(listObjects(schema));
8787
}
8888

89+
default List<ObjectInfo> listObjects(String schema, MetadataListConstraints constraints, MetadataReadOptions options) {
90+
return listObjects(schema, constraints);
91+
}
92+
8993
default List<String> listDataTypes() {
9094
return Collections.emptyList();
9195
}
@@ -104,6 +108,10 @@ default ObjectSource getObjectSource(String schema, String name, String objectTy
104108
throw new UnsupportedOperationException("Object source is not supported");
105109
}
106110

111+
default ObjectSource getObjectSource(String schema, String name, String objectType, MetadataReadOptions options) {
112+
return getObjectSource(schema, name, objectType);
113+
}
114+
107115
default ObjectSource getObjectSourceWithOrigin(String schema, String name, String objectType) {
108116
return getObjectSource(schema, name, objectType);
109117
}
@@ -184,6 +192,10 @@ default List<ConstraintInfo> listConstraints(String schema, String table) {
184192

185193
List<TriggerInfo> listTriggers(String schema, String table);
186194

195+
default List<TriggerInfo> listTriggers(String schema, String table, MetadataReadOptions options) {
196+
return listTriggers(schema, table);
197+
}
198+
187199
default List<PartitionInfo> listPartitions(String schema, String table) {
188200
return Collections.emptyList();
189201
}

‎agents/common/src/main/java/com/dbx/agent/JsonRpcServer.java‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ private Object dispatch(String method, JsonObject params) throws Exception {
253253
}
254254
if (AgentProtocol.METHOD_LIST_OBJECTS.equals(method)) {
255255
switchCatalog(params);
256+
MetadataReadOptions options = metadataReadOptions(params);
257+
if (options.exact()) return agent.listObjects(params.get("schema").getAsString(), metadataListConstraints(params), options);
256258
return agent.listObjects(params.get("schema").getAsString(), metadataListConstraints(params));
257259
}
258260
if (AgentProtocol.METHOD_LIST_DATA_TYPES.equals(method)) {
@@ -265,13 +267,16 @@ private Object dispatch(String method, JsonObject params) throws Exception {
265267
}
266268
if (AgentProtocol.METHOD_GET_OBJECT_SOURCE.equals(method)) {
267269
switchCatalog(params);
270+
MetadataReadOptions options = metadataReadOptions(params);
268271
boolean includeOrigin = params.has("include_source_origin") && params.get("include_source_origin").getAsBoolean();
269272
String schema = params.get("schema").getAsString();
270273
String name = params.get("name").getAsString();
271274
String objectType = params.get("object_type").getAsString();
272-
ObjectSource source = includeOrigin
273-
? agent.getObjectSourceWithOrigin(schema, name, objectType)
274-
: agent.getObjectSource(schema, name, objectType);
275+
ObjectSource source = options.exact()
276+
? agent.getObjectSource(schema, name, objectType, options)
277+
: includeOrigin
278+
? agent.getObjectSourceWithOrigin(schema, name, objectType)
279+
: agent.getObjectSource(schema, name, objectType);
275280
if (includeOrigin) {
276281
JsonObject result = gson.toJsonTree(source).getAsJsonObject();
277282
if (source.getSourceOrigin() != null) {
@@ -303,6 +308,8 @@ private Object dispatch(String method, JsonObject params) throws Exception {
303308
}
304309
if (AgentProtocol.METHOD_LIST_TRIGGERS.equals(method)) {
305310
switchCatalog(params);
311+
MetadataReadOptions options = metadataReadOptions(params);
312+
if (options.exact()) return agent.listTriggers(params.get("schema").getAsString(), params.get("table").getAsString(), options);
306313
return agent.listTriggers(params.get("schema").getAsString(), params.get("table").getAsString());
307314
}
308315
if (AgentProtocol.METHOD_LIST_CONSTRAINTS.equals(method)) {
@@ -669,6 +676,15 @@ private MetadataListConstraints metadataListConstraints(JsonObject params) {
669676
);
670677
}
671678

679+
private static MetadataReadOptions metadataReadOptions(JsonObject params) {
680+
String mode = stringOrNull(params, "identity_mode");
681+
String alias = stringOrNull(params, "identityMode");
682+
if (mode != null && alias != null && !mode.equals(alias)) {
683+
throw new IllegalArgumentException("Conflicting metadata identity modes");
684+
}
685+
return MetadataReadOptions.fromIdentityMode(mode != null ? mode : alias);
686+
}
687+
672688
private static int intOrDefault(JsonObject object, String key, int defaultValue) {
673689
Integer value = intOrNull(object, key);
674690
return value == null ? defaultValue : value;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.dbx.agent;
2+
3+
/** Optional read semantics; accepting an option is not proof of provider support. */
4+
public record MetadataReadOptions(boolean exact) {
5+
public static final MetadataReadOptions DEFAULT = new MetadataReadOptions(false);
6+
public static final MetadataReadOptions EXACT = new MetadataReadOptions(true);
7+
8+
public static MetadataReadOptions fromIdentityMode(String mode) {
9+
if (mode == null) return DEFAULT;
10+
if ("exact".equals(mode)) return EXACT;
11+
throw new IllegalArgumentException("Unsupported metadata identity mode");
12+
}
13+
}

‎agents/common/src/main/java/com/dbx/agent/ObjectInfo.java‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public final class ObjectInfo {
1010
private Boolean valid;
1111
private String parent_name;
1212
private String parent_schema;
13+
private TriggerInfo trigger;
1314

1415
public ObjectInfo() {
1516
this("", "", null, null, null);
@@ -71,14 +72,6 @@ public void setValid(Boolean valid) {
7172
this.valid = valid;
7273
}
7374

74-
public String getParent_name() {
75-
return parent_name;
76-
}
77-
78-
public void setParent_name(String parentName) {
79-
this.parent_name = parentName;
80-
}
81-
8275
public String getParent_schema() {
8376
return parent_schema;
8477
}
@@ -87,6 +80,22 @@ public void setParent_schema(String parentSchema) {
8780
this.parent_schema = parentSchema;
8881
}
8982

83+
public TriggerInfo getTrigger() {
84+
return trigger;
85+
}
86+
87+
public void setTrigger(TriggerInfo trigger) {
88+
this.trigger = trigger;
89+
}
90+
91+
public String getParent_name() {
92+
return parent_name;
93+
}
94+
95+
public void setParent_name(String parentName) {
96+
this.parent_name = parentName;
97+
}
98+
9099
@Override
91100
public boolean equals(Object other) {
92101
if (this == other) return true;
@@ -97,13 +106,14 @@ public boolean equals(Object other) {
97106
&& Objects.equals(schema, that.schema)
98107
&& Objects.equals(comment, that.comment)
99108
&& Objects.equals(parent_name, that.parent_name)
109+
&& Objects.equals(valid, that.valid)
100110
&& Objects.equals(parent_schema, that.parent_schema)
101-
&& Objects.equals(valid, that.valid);
111+
&& Objects.equals(trigger, that.trigger);
102112
}
103113

104114
@Override
105115
public int hashCode() {
106-
return Objects.hash(name, object_type, schema, comment, valid, parent_name, parent_schema);
116+
return Objects.hash(name, object_type, schema, comment, valid, parent_name, parent_schema, trigger);
107117
}
108118

109119
@Override

‎agents/common/src/main/java/com/dbx/agent/ObjectSource.java‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public final class ObjectSource {
88
private String schema;
99
private String source;
1010
private boolean editable;
11+
private TriggerInfo trigger;
1112
private transient String sourceOrigin;
1213

1314
public ObjectSource() {
@@ -78,6 +79,14 @@ public void setEditable(boolean editable) {
7879
this.editable = editable;
7980
}
8081

82+
public TriggerInfo getTrigger() {
83+
return trigger;
84+
}
85+
86+
public void setTrigger(TriggerInfo trigger) {
87+
this.trigger = trigger;
88+
}
89+
8190
@Override
8291
public boolean equals(Object other) {
8392
if (this == other) return true;
@@ -87,12 +96,13 @@ public boolean equals(Object other) {
8796
&& Objects.equals(object_type, that.object_type)
8897
&& Objects.equals(schema, that.schema)
8998
&& Objects.equals(source, that.source)
90-
&& editable == that.editable;
99+
&& editable == that.editable
100+
&& Objects.equals(trigger, that.trigger);
91101
}
92102

93103
@Override
94104
public int hashCode() {
95-
return Objects.hash(name, object_type, schema, source, editable);
105+
return Objects.hash(name, object_type, schema, source, editable, trigger);
96106
}
97107

98108
@Override
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.dbx.agent;
2+
3+
import java.util.List;
4+
import java.util.Map;
5+
6+
/** Raw dictionary identity. Missing fields remain unknown, not false or empty. */
7+
public record OracleTriggerMetadata(
8+
int contractVersion, String identityMode, String engine, String engineVersion,
9+
String owner, String name, String scope, String scopeType, String scopeOwner,
10+
Parent parent, String objectId, String lastDdlTime, Definition definition,
11+
List<CompilationError> errors, Map<String, ReadState> reads
12+
) {
13+
public record Parent(String owner, String name, String objectType, String objectId) {}
14+
public record Definition(String origin, String format, boolean complete) {}
15+
public record CompilationError(long sequence, long line, long position, String text, String severity) {}
16+
public record ReadState(String state, String message) {}
17+
}

0 commit comments

Comments
 (0)