|
| 1 | +syntax = "proto3"; |
| 2 | + |
| 3 | +package dataform; |
| 4 | + |
| 5 | +import "google/protobuf/empty.proto"; |
| 6 | +import "google/protobuf/struct.proto"; |
| 7 | +import "protos/core.proto"; |
| 8 | +import "protos/db_adapter.proto"; |
| 9 | + |
| 10 | +// Database adapter, available in JiT compilation context. |
| 11 | +service DbAdapter { |
| 12 | + // Executes a query. |
| 13 | + rpc Execute(ExecuteRequest) returns (ExecuteResponse) {} |
| 14 | + |
| 15 | + // Lists table in schema. |
| 16 | + rpc ListTables(ListTablesRequest) returns (ListTablesResponse) {} |
| 17 | + |
| 18 | + // Gets table for target. |
| 19 | + rpc GetTable(GetTableRequest) returns (TableMetadata) {} |
| 20 | + |
| 21 | + // Drops table of specified target. |
| 22 | + rpc DeleteTable(DeleteTableRequest) returns (google.protobuf.Empty) {} |
| 23 | +} |
| 24 | + |
| 25 | +// Request to execute synchronous SQL query. |
| 26 | +message ExecuteRequest { |
| 27 | + // SQL statement query. |
| 28 | + string statement = 1; |
| 29 | + // Max rows to return in the job. |
| 30 | + int64 row_limit = 2; |
| 31 | + // Max bytes to process. |
| 32 | + int64 byte_limit = 3; |
| 33 | + // Whether or not fetch result rows. |
| 34 | + bool fetch_results = 4; |
| 35 | + |
| 36 | + BigQueryExecuteOptions big_query_options = 5; |
| 37 | +} |
| 38 | + |
| 39 | +message BigQueryExecuteOptions { |
| 40 | + // Priority - interactive if true or batch if false (default). |
| 41 | + bool interactive = 1; |
| 42 | + // See https://docs.cloud.google.com/bigquery/docs/reference/legacy-sql. |
| 43 | + bool use_legacy_sql = 2; |
| 44 | + // Labels to add to the job. |
| 45 | + map<string, string> labels = 3; |
| 46 | + // Location to execute the job at. |
| 47 | + string location = 4; |
| 48 | + // Job prefix to add. |
| 49 | + string job_prefix = 5; |
| 50 | + // Is dry run job. |
| 51 | + bool dry_run = 6; |
| 52 | +} |
| 53 | + |
| 54 | +// Synchronous execution response result. |
| 55 | +message ExecuteResponse { |
| 56 | + // Job metadata. |
| 57 | + ExecutionMetadata execution_metadata = 1; |
| 58 | + // Rows. For BigQuery, see |
| 59 | + // https://docs.cloud.google.com/bigquery/docs/reference/rest/v2/jobs/getQueryResults. |
| 60 | + repeated google.protobuf.Struct rows = 2; |
| 61 | + repeated string errors = 3; |
| 62 | +} |
| 63 | + |
| 64 | +// Request to list tables in schema. |
| 65 | +message ListTablesRequest { |
| 66 | + string database = 1; |
| 67 | + string schema = 2; |
| 68 | +} |
| 69 | + |
| 70 | +// Tables metadata in schema. |
| 71 | +message ListTablesResponse { |
| 72 | + repeated TableMetadata tables = 1; |
| 73 | +} |
| 74 | + |
| 75 | +// Request to get table metadata for target. |
| 76 | +message GetTableRequest { |
| 77 | + Target target = 1; |
| 78 | +} |
| 79 | + |
| 80 | +// Request to drop the table for target. |
| 81 | +message DeleteTableRequest { |
| 82 | + Target target = 1; |
| 83 | +} |
| 84 | + |
| 85 | +// JiT compilation result for table actions (including views). |
| 86 | +// Fields match the Table message. |
| 87 | +message JitTableResult { |
| 88 | + // SQL Select query of the table. |
| 89 | + string query = 1; |
| 90 | + // Optional pre-operation statements. |
| 91 | + repeated string pre_ops = 3; |
| 92 | + // Optional post-operation statements. |
| 93 | + repeated string post_ops = 4; |
| 94 | +} |
| 95 | + |
| 96 | +// JiT compilation result for incremental table actions. |
| 97 | +message JitIncrementalTableResult { |
| 98 | + // Fields match the Table message. |
| 99 | + JitTableResult regular = 1; |
| 100 | + // Fields match incremental_ fields in the Table message. |
| 101 | + JitTableResult incremental = 2; |
| 102 | +} |
| 103 | + |
| 104 | +// JiT compilation result for operation actions. |
| 105 | +message JitOperationResult { |
| 106 | + // Sequence of SQL operations. |
| 107 | + repeated string queries = 1; |
| 108 | +} |
0 commit comments