You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2020/01/27 18:38:39 UTC

[GitHub] [hive] vineetgarg02 commented on a change in pull request #888: HIVE-22366: Multiple metastore calls for same table and constraints d…

vineetgarg02 commented on a change in pull request #888: HIVE-22366: Multiple metastore calls for same table and constraints d…
URL: https://github.com/apache/hive/pull/888#discussion_r371412106
 
 

 ##########
 File path: ql/src/java/org/apache/hadoop/hive/ql/metadata/Table.java
 ##########
 @@ -1126,71 +1149,167 @@ public Boolean isOutdatedForRewriting() {
     return outdatedForRewritingMaterializedView;
   }
 
-  /* These are only populated during optimization and describing */
+  public ColumnStatistics getColStats() {
+    return tTable.isSetColStats() ? tTable.getColStats() : null;
+  }
+
+  /**
+   * Setup the table level stats as if the table is new. Used when setting up Table for a new
+   * table or during replication.
+   */
+  public void setStatsStateLikeNewTable() {
+    if (isPartitioned()) {
+      StatsSetupConst.setStatsStateForCreateTable(getParameters(), null,
+          StatsSetupConst.FALSE);
+    } else {
+      StatsSetupConst.setStatsStateForCreateTable(getParameters(),
+          MetaStoreUtils.getColumnNames(getCols()), StatsSetupConst.TRUE);
+    }
+  }
+
+  /** Constraints related methods
+   *  Note that set apis are used by DESCRIBE only, although get apis return RELY or ENABLE
+   *  constraints DESCRIBE could set all type of constraints
+   * */
+
+  /* This only return PK with RELY */
   public PrimaryKeyInfo getPrimaryKeyInfo() {
+    if(!this.isPKFetched) {
+      try {
+        pki = Hive.get().getReliablePrimaryKeys(this.getDbName(), this.getTableName());
+        this.isPKFetched = true;
+      } catch (HiveException e) {
+        LOG.warn("Cannot retrieve PK info for table : " + this.getTableName()
+            + " ignoring exception: " + e);
+      }
+    }
     return pki;
   }
 
   public void setPrimaryKeyInfo(PrimaryKeyInfo pki) {
     this.pki = pki;
+    this.isPKFetched = true;
   }
 
+  /* This only return FK with RELY */
   public ForeignKeyInfo getForeignKeyInfo() {
 
 Review comment:
   Created https://issues.apache.org/jira/browse/HIVE-22782 for follow-up

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org