Spaltenspezifikationen abrufen

Abruf von Spaltenspezifikationen demonstrieren

Codebeispiel

Node.js

Für die Authentifizierung bei AutoML Tables richten Sie Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

const automl = require('@google-cloud/automl');
const client = new automl.v1beta1.AutoMlClient();

/**
 * Demonstrates using the AutoML client to get all column specs
 * information in table colums.
 * TODO(developer): Uncomment the following lines before running the sample.
 */
// const projectId = '[PROJECT_ID]' e.g., "my-gcloud-project";
// const computeRegion = '[REGION_NAME]' e.g., "us-central1";
// const datasetId = '[DATASET_ID]' e.g., "TBL2246891593778855936";
// const tableId = '[TABLE_ID]' e.g., "1991013247762825216"`;
// const columnId = '[COLUMN_ID]' e.g., "773141392279994368";

// Get the full path of the column.
const columnSpecId = client.columnSpecPath(
  projectId,
  computeRegion,
  datasetId,
  tableId,
  columnId
);

// Get all the information about a given columnSpec of a particular
// table in a dataset.
client
  .getColumnSpec({name: columnSpecId})
  .then(responses => {
    const column = responses[0];
    // Display the column spec information.
    console.log(`Column name: ${column.name}`);
    console.log(`Column Id: ${column.name.split('/').pop(-1)}`);
    console.log(`Column display name: ${column.displayName}`);
    console.log(`Column datatype: ${column.dataType.typeCode}`);
    console.log(
      `Column distinct value count: ${column.dataStats.distinctValueCount}`
    );
  })
  .catch(err => {
    console.error(err);
  });

Nächste Schritte

Informationen zum Suchen und Filtern von Codebeispielen für andere Google Cloud-Produkte finden Sie unter Google Cloud-Beispielbrowser.