MCPcopy Create free account
hub / github.com/apache/impala / load

Method load

fe/src/main/java/org/apache/impala/catalog/KuduTable.java:335–386  ·  view source on GitHub ↗

Loads the metadata of a Kudu table. Schema and partitioning schemes are loaded directly from Kudu whereas column stats are loaded from HMS. The function also updates the table schema in HMS in order to propagate alterations made to the Kudu table to HMS.

(boolean dummy /* not used */, IMetaStoreClient msClient,
      org.apache.hadoop.hive.metastore.api.Table msTbl, String reason,
      EventSequence catalogTimeline)

Source from the content-addressed store, hash-verified

333 * propagate alterations made to the Kudu table to HMS.
334 */
335 @Override
336 public void load(boolean dummy /* not used */, IMetaStoreClient msClient,
337 org.apache.hadoop.hive.metastore.api.Table msTbl, String reason,
338 EventSequence catalogTimeline) throws TableLoadingException {
339 final Timer.Context context =
340 getMetrics().getTimer(Table.LOAD_DURATION_METRIC).time();
341 Table.LOADING_TABLES.incrementAndGet();
342 try {
343 // Copy the table to check later if anything has changed.
344 msTable_ = msTbl.deepCopy();
345 kuduTableName_ = msTable_.getParameters().get(KuduTable.KEY_TABLE_NAME);
346 kuduMasters_ = msTable_.getParameters().get(KuduTable.KEY_MASTER_HOSTS);
347 if (kuduMasters_ == null || kuduMasters_.isEmpty()) {
348 throw new TableLoadingException("No " + KuduTable.KEY_MASTER_HOSTS +
349 " property found for Kudu table " + kuduTableName_);
350 }
351 setTableStats(msTable_);
352 // Load metadata from Kudu
353 final Timer.Context ctxStorageLdTime =
354 getMetrics().getTimer(Table.LOAD_DURATION_STORAGE_METADATA).time();
355 try {
356 loadSchemaFromKudu(catalogTimeline);
357 } catch (ImpalaRuntimeException e) {
358 throw new TableLoadingException("Error loading metadata for Kudu table " +
359 kuduTableName_, e);
360 } finally {
361 storageMetadataLoadTime_ = ctxStorageLdTime.stop();
362 }
363 // Load from HMS
364 loadAllColumnStats(msClient, catalogTimeline);
365 refreshLastUsedTime();
366 // Avoid updating HMS if the schema didn't change.
367 if (msTable_.equals(msTbl)) return;
368
369 // Update the table schema in HMS.
370 try {
371 // HMS would fill this table property if it was not set, but as metadata written
372 // with alter_table is not read back in case of Kudu tables, it has to be set here
373 // to ensure that HMS and catalogd have the same timestamp.
374 updateTimestampProperty(msTable_, TBL_PROP_LAST_DDL_TIME);
375 msTable_.putToParameters(StatsSetupConst.DO_NOT_UPDATE_STATS,
376 StatsSetupConst.TRUE);
377 msClient.alter_table(msTable_.getDbName(), msTable_.getTableName(), msTable_);
378 catalogTimeline.markEvent("Updated table schema in Metastore");
379 } catch (TException e) {
380 throw new TableLoadingException(e.getMessage());
381 }
382 } finally {
383 Table.LOADING_TABLES.decrementAndGet();
384 context.stop();
385 }
386 }
387
388 /**
389 * Loads the schema from the Kudu table including column definitions and primary key

Callers

nothing calls this directly

Calls 15

loadSchemaFromKuduMethod · 0.95
getTimerMethod · 0.80
setTableStatsMethod · 0.80
loadAllColumnStatsMethod · 0.80
refreshLastUsedTimeMethod · 0.80
putToParametersMethod · 0.80
getMethod · 0.65
getParametersMethod · 0.65
stopMethod · 0.65
getTableNameMethod · 0.65
getMetricsMethod · 0.45

Tested by

no test coverage detected