열 사양 가져오기

열 사양을 가져오는 방법을 보여줍니다.

코드 샘플

Node.js

AutoML Tables에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

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

다음 단계

다른 Google Cloud 제품의 코드 샘플을 검색하고 필터링하려면 Google Cloud 샘플 브라우저를 참조하세요.