Obtenir les spécifications des colonnes

Démontrer l'extraction de spécifications de colonnes

Exemple de code

Node.js

Pour vous authentifier auprès d'AutoML Tables, configurez les Identifiants par défaut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de développement local.

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);
  });

Étapes suivantes

Pour rechercher et filtrer des exemples de code pour d'autres produits Google Cloud, consultez l'exemple de navigateur Google Cloud.