This is an automated email from the ASF dual-hosted git repository.
ayushsaxena pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new fbe090f5edf HIVE-28909: Modify McolumnDescriptor definition in
package.jdo to support JDK17 + JDO6.0 (#5804)
fbe090f5edf is described below
commit fbe090f5edf098e573749e40fdb6519cdc615682
Author: Sai Hemanth Gantasala
<[email protected]>
AuthorDate: Fri May 23 08:24:47 2025 -0700
HIVE-28909: Modify McolumnDescriptor definition in package.jdo to support
JDK17 + JDO6.0 (#5804)
---
.../model/{MFieldSchema.java => MColumn.java} | 104 +++++++++++++--------
.../hive/metastore/model/MColumnDescriptor.java | 36 +++++--
.../hadoop/hive/metastore/model/MFieldSchema.java | 1 -
.../src/main/resources/package.jdo | 50 +++++-----
4 files changed, 114 insertions(+), 77 deletions(-)
diff --git
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/model/MFieldSchema.java
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/model/MColumn.java
similarity index 54%
copy from
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/model/MFieldSchema.java
copy to
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/model/MColumn.java
index 05117bdad72..8bdb81e9891 100644
---
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/model/MFieldSchema.java
+++
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/model/MColumn.java
@@ -16,65 +16,87 @@
* limitations under the License.
*/
-/**
- *
- */
package org.apache.hadoop.hive.metastore.model;
-/**
- * Represent a column or a type of a table or object
- */
-public class MFieldSchema {
+import java.io.Serializable;
+import java.util.Objects;
+
+import org.datanucleus.identity.LongId;
+
+public class MColumn {
+ private MColumnDescriptor cd;
private String name;
private String type;
private String comment;
- public MFieldSchema() {}
-
- /**
- * @param comment
- * @param name
- * @param type
- */
- public MFieldSchema(String name, String type, String comment) {
- this.comment = comment;
+
+ @SuppressWarnings("serial")
+ public static class PK implements Serializable {
+ public LongId cd;
+ public String name;
+
+ public PK() {}
+
+ public PK(LongId id, String name) {
+ this.cd = id;
+ this.name = name;
+ }
+
+ public String toString() {
+ return String.format("%s-%s", cd.toString(), name);
+ }
+
+ public int hashCode() {
+ return Objects.hash(cd.getKey(), name);
+ }
+
+ public boolean equals(Object other) {
+ if (other instanceof PK) {
+ PK otherPK = (PK)other;
+ return Objects.equals(otherPK.name, name)
+ && Objects.equals(otherPK.cd.getKey(), cd.getKey());
+ }
+ return false;
+ }
+ }
+
+ public MColumn() {
+ }
+
+ public MColumn(String name, String type, String comment) {
this.name = name;
this.type = type;
+ this.comment = comment;
+ }
+
+ public MColumnDescriptor getCd() {
+ return cd;
}
- /**
- * @return the name
- */
+
+ public void setCd(MColumnDescriptor cd) {
+ this.cd = cd;
+ }
+
public String getName() {
return name;
}
- /**
- * @param name the name to set
- */
+
public void setName(String name) {
this.name = name;
}
- /**
- * @return the comment
- */
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
public String getComment() {
return comment;
}
- /**
- * @param comment the comment to set
- */
+
public void setComment(String comment) {
this.comment = comment;
}
- /**
- * @return the type
- */
- public String getType() {
- return type;
- }
- /**
- * @param field the type to set
- */
- public void setType(String field) {
- this.type = field;
- }
-
}
diff --git
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/model/MColumnDescriptor.java
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/model/MColumnDescriptor.java
index a776e484c78..d25eb272109 100644
---
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/model/MColumnDescriptor.java
+++
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/model/MColumnDescriptor.java
@@ -21,6 +21,9 @@
*/
package org.apache.hadoop.hive.metastore.model;
+import javax.jdo.annotations.NotPersistent;
+import java.util.ArrayList;
+import java.util.stream.Collectors;
import java.util.List;
/**
@@ -29,23 +32,38 @@
* A wrapper around a list of columns.
*/
public class MColumnDescriptor {
- private List<MFieldSchema> cols;
+ private List<MColumn> fields;
+
+ @NotPersistent
+ private List<MFieldSchema> columns;
+ private long id;
public MColumnDescriptor() {}
- /**
- *
- * @param cols
- */
public MColumnDescriptor(List<MFieldSchema> cols) {
- this.cols = cols;
+ fields = cols.stream().map(schema ->
+ new MColumn(schema.getName(), schema.getType(), schema.getComment()))
+ .collect(Collectors.toList());
+ }
+
+ public List<MColumn> getFields() {
+ return fields;
}
public List<MFieldSchema> getCols() {
- return cols;
+ if (columns != null) {
+ return columns;
+ }
+ columns = new ArrayList<>();
+ if (fields != null) {
+ columns = fields.stream().map(column ->
+ new MFieldSchema(column.getName(), column.getType(),
column.getComment()))
+ .collect(Collectors.toList());
+ }
+ return columns;
}
- public void setCols(List<MFieldSchema> cols) {
- this.cols = cols;
+ public long getId() {
+ return id;
}
}
diff --git
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/model/MFieldSchema.java
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/model/MFieldSchema.java
index 05117bdad72..772cedb9efb 100644
---
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/model/MFieldSchema.java
+++
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/model/MFieldSchema.java
@@ -76,5 +76,4 @@ public String getType() {
public void setType(String field) {
this.type = field;
}
-
}
diff --git
a/standalone-metastore/metastore-server/src/main/resources/package.jdo
b/standalone-metastore/metastore-server/src/main/resources/package.jdo
index 5e2f686bff8..955e2209c47 100644
--- a/standalone-metastore/metastore-server/src/main/resources/package.jdo
+++ b/standalone-metastore/metastore-server/src/main/resources/package.jdo
@@ -115,6 +115,22 @@
</field>
</class>
+ <class name="MColumn" identity-type="application" table="COLUMNS_V2"
detachable="true" objectid-class="MColumn$PK">
+ <foreign-key name="CD_ID" delete-action="cascade"/>
+ <field name="cd" primary-key="true">
+ <column name="CD_ID"/>
+ </field>
+ <field name="name" primary-key="true">
+ <column name="COLUMN_NAME" length="767" jdbc-type="VARCHAR"
allows-null="false"/>
+ </field>
+ <field name="type">
+ <column name="TYPE_NAME" length="32672" jdbc-type="VARCHAR"
allows-null="false"/>
+ </field>
+ <field name="comment">
+ <column name="COMMENT" length="256" jdbc-type="VARCHAR"
allows-null="true"/>
+ </field>
+ </class>
+
<class name="MType" table="TYPES" detachable="true">
<field name="name" >
<column name="TYPE_NAME" length="128" jdbc-type="VARCHAR"/>
@@ -364,33 +380,15 @@
</field>
</class>
- <class name="MColumnDescriptor" identity-type="datastore" table="CDS"
detachable="true">
- <datastore-identity>
- <column name="CD_ID"/>
- </datastore-identity>
- <field name="cols" persistence-modifier="persistent" table="COLUMNS_V2">
- <collection element-type="MFieldSchema" dependent-element="true" />
- <join>
- <primary-key name="SQL110922153006740">
- <column name="CD_ID"/>
- <column name="COLUMN_NAME"/>
- </primary-key>
- <column name="CD_ID"/>
- </join>
- <element>
- <embedded>
- <field name="name">
- <column name="COLUMN_NAME" length="767" jdbc-type="VARCHAR"
allows-null="false"/>
- </field>
- <field name="type">
- <column name="TYPE_NAME" length="32672" jdbc-type="VARCHAR"
allows-null="false"/>
- </field>
- <field name="comment">
- <column name="COMMENT" length="256" jdbc-type="VARCHAR"
allows-null="true"/>
- </field>
- </embedded>
- </element>
+ <class name="MColumnDescriptor" identity-type="application" table="CDS"
detachable="true">
+ <field name="id" primary-key="true" value-strategy="native">
+ <column name="CD_ID" jdbc-type="BIGINT" />
+ </field>
+ <field name="fields" mapped-by="cd">
+ <order column="INTEGER_IDX"/>
+ <collection element-type="MColumn" dependent-element="true" />
</field>
+ <field name="columns" persistence-modifier="none" />
</class>
<class name="MStringList" identity-type="datastore"
table="Skewed_STRING_LIST" detachable="true">