All Products
Search
Document Center

Object Storage Service:create-select-object-meta

Last Updated:Sep 24, 2024

The create-select-object-meta command is used to query information about target objects, such as the total number of rows and the total number of columns in CSV objects, and the number of splits. If the requested information does not exist in the object, the system scans the entire object to analyze and save the preceding information. When you call the API operation on the object again, the saved information is returned. The system does not scan the entire object.

Usage notes

By default, an Alibaba Cloud account has the permissions to manage objects. Managing objects as a RAM user or by using Security Token Service (STS) requires oss:PutObject permission. For more information, see Attach a custom policy to a RAM user.

Command syntax

ossutil api create-select-object-meta --bucket value --key value --select-meta-request value [flags]

Parameter

Type

Description

--bucket

string

Name of the bucket.

--key

string

Full path of the object.

--select-meta-request

string

Container that stores the CreateSelectObjectMeta request.

Note

The create-select-object-meta command corresponds to the CreateSelectObjectMeta operation. For more information about the parameters in the CreateSelectObjectMeta operation, see CreateSelectObjectMeta.

--select-meta-request

The --select-meta-request configuration option supports both XML and JSON formats. If the value of the option contains the 'file://' prefix, configuration parameters are read from the specified file.

  • XML format:

    <SelectMetaRequest>
      <InputSerialization>
        <CompressionType>string</CompressionType>
        <CSV>
          <RecordDelimiter>string</RecordDelimiter>
          <FieldDelimiter>string</FieldDelimiter>
          <QuoteCharacter>string</QuoteCharacter>
          <CommentCharacter>string</CommentCharacter>
          <Range>string</Range>
          <AllowQuotedRecordDelimiter>boolean</AllowQuotedRecordDelimiter>
          <FileHeaderInfo>string</FileHeaderInfo>
        </CSV>
        <JSON>
          <Range>string</Range>
          <ParseJsonNumberAsString>boolean</ParseJsonNumberAsString>
          <Type>string</Type>
        </JSON>
      </InputSerialization>
      <OverwriteIfExists>boolean</OverwriteIfExists>
    </SelectMetaRequest>
  • JSON format:

    {
      "InputSerialization": {
        "CompressionType": "string",
        "CSV": {
          "CommentCharacter": "string",
          "Range": "string",
          "AllowQuotedRecordDelimiter": boolean,
          "FileHeaderInfo": "string",
          "RecordDelimiter": "string",
          "FieldDelimiter": "string",
          "QuoteCharacter": "string"
        },
        "JSON": {
          "Type": "string",
          "Range": "string",
          "ParseJsonNumberAsString": boolean
        }
      },
      "OverwriteIfExists": boolean
    }
Note

For more information about supported global command-line options, see Command-line options.

Examples

  • Query information about exampleobject in examplebucket, such as the total number of rows, columns, and the number of splits. This operation supports the request syntax for CSV objects.

    • Create a configuration file named select-meta-request.xml and add the following code:

      <?xml version="1.0"?>
      <CsvMetaRequest>
          <InputSerialization>
              <CSV>
                  <RecordDelimiter>Cg==</RecordDelimiter>
                  <FieldDelimiter>LA==</FieldDelimiter>
                  <QuoteCharacter>Ig==</QuoteCharacter>
              </CSV>
          </InputSerialization>
          <OverwriteIfExisting>false</OverwriteIfExisting>
      </CsvMetaRequest>

      Sample command:

      ossutil api create-select-object-meta --bucket examplebucket --key exampleobject --select-meta-request file://select-meta-request.xml
    • Create a configuration file named select-meta-request.json and add the following code:

      {
        "InputSerialization": {
          "CSV": {
            "RecordDelimiter": "Cg==",
            "FieldDelimiter": "LA==",
            "QuoteCharacter": "Ig=="
          }
        },
        "OverwriteIfExisting": "false"
      }

      Sample command:

      ossutil api create-select-object-meta --bucket examplebucket --key exampleobject --select-meta-request file://select-meta-request.json
    • Configure parameters in the following command in the JSON format:

      ossutil api create-select-object-meta --bucket examplebucket --key exampleobject --select-meta-request "{\"InputSerialization\":{\"CSV\":{\"RecordDelimiter\":\"Cg==\",\"FieldDelimiter\":\"LA==\",\"QuoteCharacter\":\"Ig==\"}},\"OverwriteIfExisting\":\"false\"}"

  • Query information about exampleobject in examplebucket, such as the total number of rows, columns, and the number of splits. This operation supports the request syntax for JSON objects.

    • Create a configuration file named select-request.xml and add the following code:

      <?xml version="1.0"?>
      <JsonMetaRequest>
          <InputSerialization>
              <JSON>
                  <Type>LINES</Type>
              </JSON>
          </InputSerialization>
          <OverwriteIfExisting>false</OverwriteIfExisting>
      </JsonMetaRequest>

      Sample command:

      ossutil api create-select-object-meta --bucket examplebucket --key exampleobject --select-meta-request file://select-meta-request.xml
    • Create a configuration file named select-request.json and add the following code:

      {
        "InputSerialization": {
          "JSON": {
            "Type": "LINES"
          }
        },
        "OverwriteIfExisting": "false"
      }

      Sample command:

      ossutil api create-select-object-meta --bucket examplebucket --key exampleobject --select-meta-request file://select-meta-request.json
    • Configure parameters in the following command in the JSON format:

      ossutil api create-select-object-meta --bucket examplebucket --key exampleobject --select-meta-request "{\"InputSerialization\":{\"JSON\":{\"Type\":\"LINES\"}},\"OverwriteIfExisting\":\"false\"}"