Skip to content

Picosecond support#1365

Draft
KanchanShu wants to merge 1 commit into
mainfrom
picosecond_support
Draft

Picosecond support#1365
KanchanShu wants to merge 1 commit into
mainfrom
picosecond_support

Conversation

@KanchanShu
Copy link
Copy Markdown
Collaborator

@KanchanShu KanchanShu commented Jan 8, 2026

This is a test PR created to validate picosecond support in the driver.

The following changes were made as part of this validation:

  • Populated the picosecond support parameter timestamp_output_format.
  • Modified several test cases to verify picosecond support.

Create callback:

{
  "kind": "bigquery#queryResponse",
  "schema": {
    "fields": [
      {
        "name": "Id",
        "type": "INTEGER"
      },
      {
        "name": "DOB",
        "type": "TIMESTAMP",
        "timestampPrecision": "12"
      }
    ]
  },
  "jobReference": {
    "projectId": "bigquery-devtools-drivers",
    "jobId": "job_4SU-yFhDwhU6MkF450u8ej0YdMi9",
    "location": "US"
  },
  "totalBytesProcessed": "0",
  "jobComplete": true,
  "cacheHit": false,
  "queryId": "job_4SU-yFhDwhU6MkF450u8ej0YdMi9",
  "jobCreationReason": {
    "code": "REQUESTED"
  },
  "totalBytesBilled": "0",
  "totalSlotMs": "0",
  "location": "US",
  "creationTime": "1770104166525",
  "startTime": "1770104166673",
  "endTime": "1770104166794"
}

Insert Callback:

{
  "kind": "bigquery#job",
  "etag": "+WN6H/c5LVKHpWTtCHQ/fQ==",
  "id": "bigquery-devtools-drivers:US.",
  "selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/bigquery-devtools-drivers/jobs/?location=US",
  "user_email": "bq-devtools-simba-drivers-test@bigquery-devtools-drivers.iam.gserviceaccount.com",
  "configuration": {
    "query": {
      "query": "INSERT INTO ODBC_TEST_DATASET._ODBC_INSERT_TEST_TIMESTAMP_Picosecond (Id, DOB) VALUES (1, '2024-01-20 10:20:30.123456789123'), (2, '2024-01-20 11:02:33.001212123456'), (3, '2024-01-20 02:20:22.123123123451')",
      "destinationTable": {
        "projectId": "bigquery-devtools-drivers",
        "datasetId": "ODBC_TEST_DATASET",
        "tableId": "_ODBC_INSERT_TEST_TIMESTAMP_Picosecond"
      },
      "priority": "INTERACTIVE",
      "allowLargeResults": false,
      "useQueryCache": true,
      "flattenResults": false,
      "useLegacySql": false,
      "parameterMode": "NAMED",
      "scriptOptions": {
        "statementTimeoutMs": "0",
        "statementByteBudget": "0",
        "keyResultStatement": "LAST"
      }
    },
    "dryRun": true,
    "jobTimeoutMs": "0",
    "jobType": "QUERY"
  },
  "jobReference": {
    "projectId": "bigquery-devtools-drivers",
    "location": "US"
  },
  "statistics": {
    "creationTime": "1770104169194",
    "totalBytesProcessed": "0",
    "query": {
      "totalBytesProcessed": "0",
      "totalBytesBilled": "0",
      "cacheHit": false,
      "referencedTables": [
        {
          "projectId": "bigquery-devtools-drivers",
          "datasetId": "ODBC_TEST_DATASET",
          "tableId": "_ODBC_INSERT_TEST_TIMESTAMP_Picosecond"
        }
      ],
      "schema": {
        "fields": [
          {
            "name": "Id",
            "type": "INTEGER",
            "mode": "NULLABLE"
          },
          {
            "name": "DOB",
            "type": "TIMESTAMP",
            "mode": "NULLABLE",
            "timestampPrecision": "12"
          }
        ]
      },
      "statementType": "INSERT",
      "totalBytesProcessedAccuracy": "PRECISE"
    }
  },
  "status": {
    "state": "DONE"
  },
  "principal_subject": "serviceAccount:bq-devtools-simba-drivers-test@bigquery-devtools-drivers.iam.gserviceaccount.com"
}

Select Callback:

{
  "kind": "bigquery#queryResponse",
  "schema": {
    "fields": [
      {
        "name": "DOB",
        "type": "TIMESTAMP",
        "mode": "NULLABLE",
        "timestampPrecision": "12"
      }
    ]
  },
  "jobReference": {
    "projectId": "bigquery-devtools-drivers",
    "jobId": "job_YoT_4BKWd1-bqB_jKy8GOuSCuUoj",
    "location": "US"
  },
  "totalRows": "3",
  "rows": [
    {
      "f": [
        {
          "v": "2024-01-20T10:20:30.123456789123Z"
        }
      ]
    },
    {
      "f": [
        {
          "v": "2024-01-20T11:02:33.001212123456Z"
        }
      ]
    },
    {
      "f": [
        {
          "v": "2024-01-20T02:20:22.123123123451Z"
        }
      ]
    }
  ],
  "totalBytesProcessed": "72",
  "jobComplete": true,
  "cacheHit": false,
  "queryId": "job_YoT_4BKWd1-bqB_jKy8GOuSCuUoj",
  "jobCreationReason": {
    "code": "REQUESTED"
  },
  "totalBytesBilled": "10485760",
  "totalSlotMs": "212",
  "location": "US",
  "creationTime": "1770104175731",
  "startTime": "1770104175835",
  "endTime": "1770104176177"
}

Drop callback:

{
  "kind": "bigquery#job",
  "etag": "zXlV3b1W4Ca73ps44dWOTw==",
  "id": "bigquery-devtools-drivers:US.",
  "selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/bigquery-devtools-drivers/jobs/?location=US",
  "user_email": "bq-devtools-simba-drivers-test@bigquery-devtools-drivers.iam.gserviceaccount.com",
  "configuration": {
    "query": {
      "query": "DROP TABLE IF EXISTS ODBC_TEST_DATASET._ODBC_INSERT_TEST_TIMESTAMP_Picosecond",
      "destinationTable": {
        "projectId": "bigquery-devtools-drivers",
        "datasetId": "ODBC_TEST_DATASET",
        "tableId": "_ODBC_INSERT_TEST_TIMESTAMP_Picosecond"
      },
      "priority": "INTERACTIVE",
      "allowLargeResults": false,
      "useQueryCache": true,
      "flattenResults": false,
      "useLegacySql": false,
      "scriptOptions": {
        "statementTimeoutMs": "0",
        "statementByteBudget": "0",
        "keyResultStatement": "LAST"
      }
    },
    "dryRun": true,
    "jobTimeoutMs": "0",
    "jobType": "QUERY"
  },
  "jobReference": {
    "projectId": "bigquery-devtools-drivers",
    "location": "US"
  },
  "statistics": {
    "creationTime": "1770104178721",
    "totalBytesProcessed": "0",
    "query": {
      "totalBytesProcessed": "0",
      "totalBytesBilled": "0",
      "cacheHit": false,
      "statementType": "DROP_TABLE",
      "ddlOperationPerformed": "DROP",
      "ddlTargetTable": {
        "projectId": "bigquery-devtools-drivers",
        "datasetId": "ODBC_TEST_DATASET",
        "tableId": "_ODBC_INSERT_TEST_TIMESTAMP_Picosecond"
      },
      "totalBytesProcessedAccuracy": "PRECISE"
    }
  },
  "status": {
    "state": "DONE"
  },
  "principal_subject": "serviceAccount:bq-devtools-simba-drivers-test@bigquery-devtools-drivers.iam.gserviceaccount.com"
}

Full test-suite run on local:
image

@Khushikathuria008 Khushikathuria008 force-pushed the picosecond_support branch 4 times, most recently from e2fb822 to 589051a Compare January 29, 2026 07:56

void InsertTimestampData(std::shared_ptr<ODBCHandles> const& conn,
std::vector<SQL_TIMESTAMP_STRUCT> rows,
std::vector<std::string> rows,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this modified?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timestamp struct only contains fractions upto 9 digits. We are utilising this func in picoseconds as well.Hence updated it.

<< (row.minute < 10 ? "0" : "") << row.minute << ":"
<< (row.second < 10 ? "0" : "") << row.second << "."
<< row.fraction << "'";
// if (row.year != 0) {
Copy link
Copy Markdown
Collaborator

@shivamd-gpartner shivamd-gpartner Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are so many of these unnecessary code, remove it if not needed

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

std::string insert_stmt_str = insert_stmt.str();
SQLRETURN status;

std::cout << "Insert Timestamp Statement: " << insert_stmt_str << std::endl;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove these prints

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Khushikathuria008 Khushikathuria008 force-pushed the picosecond_support branch 3 times, most recently from 64602a3 to 41805f5 Compare February 3, 2026 05:11
*res_len = kTimestampBinaryLength;
}
timestamp_src_struct.fraction = timestamp_src_struct.fraction * 1000;
timestamp_src_struct.fraction = timestamp_src_struct.fraction;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we removed this 1000 factor here?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it was always converting to nanoseconds. even when not needed.

&ts.month, &ts.day, &ts.hour, &ts.minute, &ts.second, &micro);
}

if (matched < 6) {
Copy link
Copy Markdown
Collaborator

@shivamd-gpartner shivamd-gpartner Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this working? we have duplicate blocks of if condition and if needed see if can be combined

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@shivamd-gpartner
Copy link
Copy Markdown
Collaborator

@Khushikathuria008 also add full test cases output

@Khushikathuria008 Khushikathuria008 force-pushed the picosecond_support branch 4 times, most recently from 5b972cb to 17776b4 Compare February 5, 2026 10:02

DSRow CreateDSRowFromTypeInfo(TypeInfoRow const& type_info) {
bool IsTimeRelated(TypeInfoRow const& type_info) {
return type_info.sql_data_type == SQL_TYPE_TIMESTAMP ||
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have we verified Date also has picoseconds support?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. date doesnt support it.

@shivamd-gpartner shivamd-gpartner marked this pull request as ready for review February 13, 2026 09:55
@shivamd-gpartner shivamd-gpartner requested review from a team and sachinpro February 13, 2026 09:55
@Khushikathuria008 Khushikathuria008 requested a review from a team as a code owner March 16, 2026 10:04
@Khushikathuria008 Khushikathuria008 marked this pull request as draft March 16, 2026 10:12
@Khushikathuria008 Khushikathuria008 removed the request for review from sachinpro March 16, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants