열 또는 column family 형식을 지정하려면 해당 열의 형식을 지정하는 YAML 파일을 제공해야 합니다. cbt lookup 또는 cbt read를 호출하면 format-file 인수를 사용하여 YAML 파일로 경로를 전달합니다. 다음 스니펫은 제공된 format-file 인수를 사용하여 cbt lookup을 호출하는 예시를 보여줍니다.
protocol_buffer_definitions 필드는 protobuf 데이터 디코딩에 사용할 프로토콜 버퍼 메시지 유형을 포함할 수 있는 .proto 파일의 목록을 제공합니다.
protocol_buffer_paths 필드는 프로토콜 버퍼 유형을 디코딩하기 위해 사용되는 .proto 파일을 포함할 수 있는 로컬 경로 목록을 제공합니다.
google/protobuf 패키지의 메시지와 같이 표준 프로토콜 버퍼 가져오기 위치를 지정할 필요가 없습니다.
columns 필드에는 각 열의 해당 데이터 유형과 함께 열 이름 목록이 포함됩니다.
protobuf 열의 encoding은 'ProtocolBuffer'로 설정되고 type은 'Cat'으로 설정됩니다. cbt CLI는 이 열에 저장된 모든 값을 Cat proto 메시지 유형으로 해석하고 형식을 지정합니다. 유형은 protocol_buffer_definition 필드에 제공된 .proto 파일 중 하나에 정의된 메시지 유형과 일치해야 합니다.
json 열의 encoding 필드가 'JSON'으로 설정되어 있습니다. cbt는 이 열에 저장된 모든 값을 JSON 구조로 해석하고 형식을 지정합니다.
제공할 수 있는 다른 필드는 다음과 같습니다.
default_encoding: 이 필드는 테이블의 모든 열이나 column family의 모든 열에 대한 기본 형식 지정을 정의합니다.
default_type: 이 필드는 프로토콜 버퍼, big-endian, little-endian 인코딩 열의 기본 데이터 유형을 정의합니다.
families: 이 필드는 column family 내 모든 열의 인코딩과 유형을 정의합니다. column family에 default_encoding 및 default_type을 제공할 수 있습니다. 다음 스니펫과 같이 적절한 인코딩 및 데이터 유형으로 열을 이름별로 나열하는 columns 필드를 제공하여 열 수준에서 이러한 인코딩을 재정의할 수도 있습니다.
cbt CLI는 여러 복잡한 데이터 유형의 형식 지정을 지원합니다. 다음 표는 각 목록 유형에 대해 YAML 파일에 제공할 지원되는 데이터 유형 및 문자열을 보여줍니다. 문자열 값은 대소문자를 구분하지 않습니다.
데이터 유형
YAML 값 형식 지정
16진수
Hex, H
Big-endian
BigEndian, B
Little-endian
LittleEndian, L
프로토콜 버퍼
ProtocolBuffer, P, PROTO
JSON
JSON, J
표 1.cbt 출력에서 형식 지정에 지원되는 데이터 유형.
16진수 인코딩은 유형에 구애받지 않습니다. 데이터는 저장된 데이터의 원시 16진수 표현으로 표시됩니다.
big-endian 및 little-endian 인코딩에 사용할 수 있는 유형은 int8, int16, int32, int64, uint8, uint16, uint32, uint64 ,float32, float64입니다. 저장된 데이터 길이는 크기가 유형 크기의 배수(바이트)여야 합니다. 저장된 길이가 유형 크기와 일치하는 경우 데이터는 스칼라로 표시되고 그렇지 않은 경우에는 배열로 표시됩니다. 유형 이름은 대소문자를 구분하지 않습니다.
프로토콜 버퍼 인코딩에 지정된 유형은 제공된 프로토콜 버퍼 정의 파일에 정의된 메시지 유형과 일치해야 합니다. 유형은 대소문자를 구분하지 않습니다.
유형을 지정하지 않으면 기본값은 표시되는 열 데이터의 열 이름으로 설정됩니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eThe \u003ccode\u003ecbt\u003c/code\u003e CLI can format complex data types stored in Bigtable rows for improved readability when using \u003ccode\u003ecbt read\u003c/code\u003e or \u003ccode\u003ecbt lookup\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eFormatting is defined in a YAML file, specifying data types and encodings for columns or column families, which is then passed to the \u003ccode\u003ecbt\u003c/code\u003e CLI using the \u003ccode\u003eformat-file\u003c/code\u003e argument.\u003c/p\u003e\n"],["\u003cp\u003eYAML formatting can include protocol buffer definitions and paths, allowing for the decoding and display of protobuf messages stored in Bigtable.\u003c/p\u003e\n"],["\u003cp\u003eSupported data types for formatting include hexadecimal, big-endian, little-endian, protocol buffer, and JSON, each with specific formatting values for the YAML file.\u003c/p\u003e\n"],["\u003cp\u003eA default formatting can be applied to an entire table, or specific column family in the YAML file, including default type, and encoding, with the possibility to override these at the column level.\u003c/p\u003e\n"]]],[],null,["# Format output from the cbt CLI\n\nFormat output from the\ncbt CLI\n==============================\n\nThis document describes how to format specific types of data stored in\nBigtable rows when displayed by the\n`cbt` CLI\n.\n\nExamples of formatting\n----------------------\n\nStarting with version 0.12.0, the\n`cbt` CLI\ncan format\n[certain complex types](#data-types) of data stored in table rows.\nWhen you use the `cbt read` or `cbt lookup` command, the\n`cbt` CLI\ncan\n\"pretty print\" values stored in the rows.\n\nThe following example shows data output from the\n`cbt` CLI\nwithout\nformatting. \n\n ----------------------------------------\n r1\n fam1:col1 @ 2022/03/09-11:19:45.966000\n \"\\n\\x05Brave\\x10\\x02\"\n fam1:col2 @ 2022/03/14-11:17:20.014000\n \"{\\\"name\\\": \\\"Brave\\\", \\\"age\\\": 2}\"\n\nThe following example shows data output from the\n`cbt` CLI\nwith\nformatting. \n\n r1\n fam1:col1 @ 2022/03/09-11:19:45.966000\n name: \"Brave\"\n age: 2\n fam1:col2 @ 2022/03/14-11:17:20.014000\n age: 2.00\n name: \"Brave\"\n\nPrint rows with formatting\n--------------------------\n\nTo format a column or column family, you must provide a YAML file that\nspecifies the formatting for that column. When you call `cbt lookup` or\n`cbt read`, you pass in the path to the YAML file with the `format-file`\nargument. The following snippet shows an example of calling `cbt lookup` with\nthe `format-file` argument supplied. \n\n cbt lookup my-table r1 format-file=/path/to/formatting.yml\n\n### Define column data formats in YAML\n\nThe formatting YAML file must connect the column names or column family names\nwith the data types stored within them. The following snippet shows an example\nof a YAML formatting file. \n\n protocol_buffer_definitions:\n - cat.proto\n protocol_buffer_paths:\n - testdata/\n\n\n columns:\n col1:\n encoding: ProtocolBuffer\n type: Cat\n\n col2:\n encoding: json\n\nThe following snippet shows the contents of 'cat.proto'. \n\n syntax = \"proto3\";\n package cats;\n\n option go_package = \"github.com/protocolbuffers/protobuf/examples/go/tutorialpb\";\n\n message Cat {\n string name = 1;\n int32 age = 2;\n }\n\nLooking at the example:\n\n- The `protocol_buffer_definitions` field provides a list of .proto files that can contain protocol buffer message types to use for decoding protobuf data.\n- The `protocol_buffer_paths` field provides a list of local paths that can contain .proto files for decoding protocol buffer types. You do not need to specify the locations of standard protocol buffer imports, such as messages in the `google/protobuf` package.\n- The `columns` field contains a list of column names with the corresponding\n data types for each column:\n\n - The `protobuf` column has its `encoding` set to \"ProtocolBuffer\" and its `type` is set to 'Cat'. The `cbt` CLI interprets and formats all values stored in this column as a `Cat` proto message type. The type must correspond to a message type defined in one of the .proto files provided for the `protocol_buffer_definition` field.\n - The `json` column has its `encoding` field set to \"json\". The `cbt` interprets and formats all values stored in this column as a JSON structure.\n\nOther fields that you can provide:\n\n- `default_encoding`: This field defines a default formatting for all all columns in a table or all columns in a column family.\n- `default_type`: This field defines a default data type for protocol buffer, big-endian, and little-endian encoded columns.\n- `families`: This field defines encodings and types for all columns within\n a column family. You can provide a `default_encoding` and `default_type`\n for a column family. You can also override these encodings at the column\n level by providing a `columns` field that lists columns by name with the\n appropriate encoding and data types, as shown in the following snippet:\n\n families:\n family1:\n default_encoding: BigEndian\n default_type: INT64\n columns:\n address:\n encoding: PROTO\n type: tutorial.Person\n\nSupported data types\n--------------------\n\nThe\n`cbt` CLI\nsupports formatting for several complex data types. The following\ntable lists the supported data types and strings to provide in the YAML file\nfor each of the list types. String values are not case-sensitive.\n\n**Table 1.** Data types supported for formatting in `cbt` output.\n\n- The hexadecimal encoding is type agnostic. Data are displayed as a raw hexadecimal representation of the stored data.\n- The available types for the big-endian and little-endian encodings are `int8`, `int16`, `int32`, `int64`, `uint8`, `uint16`, `uint32`, `uint64`, `float32`, and `float64`. Stored data length must be a multiple of the type sized, in bytes. Data are displayed as scalars if the stored length matches the type size, or as arrays otherwise. Types names are not case-sensitive.\n- The types given for the *protocol-buffer* encoding must match message types defined in provided protocol-buffer definition files. The types are not case-sensitive. If no type is specified, it defaults to the column name for the column data being displayed.\n- The formatting values for YAML are not case-sensitive."]]