Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: BigQuery query span type and DML statement handling (#18077)

Vincent Huang0347c99058e2
diff --git a/backend/plugin/db/bigquery/bigquery.go b/backend/plugin/db/bigquery/bigquery.go
index 0fa5bc3dcf..2e44f4ae27 100644
--- a/backend/plugin/db/bigquery/bigquery.go
+++ b/backend/plugin/db/bigquery/bigquery.go
@@ -117,13 +117,12 @@ func (d *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, q
var results []*v1pb.QueryResult
for _, statement := range statements {
- if queryContext.Limit > 0 {
- statement = getStatementWithResultLimit(statement, queryContext.Limit)
- }
-
startTime := time.Now()
queryResult, err := func() (*v1pb.QueryResult, error) {
if util.IsSelect(statement) {
+ if queryContext.Limit > 0 {
+ statement = getStatementWithResultLimit(statement, queryContext.Limit)
+ }
q := d.client.Query(statement)
if queryContext.OperatorEmail != "" {
q.Labels = map[string]string{"operator_email": encodeOperatorEmail(queryContext.OperatorEmail)}
diff --git a/backend/plugin/parser/bigquery/query_span_extractor.go b/backend/plugin/parser/bigquery/query_span_extractor.go
index 830fc40e02..b641b30d01 100644
--- a/backend/plugin/parser/bigquery/query_span_extractor.go
+++ b/backend/plugin/parser/bigquery/query_span_extractor.go
@@ -86,6 +86,7 @@ func (q *querySpanExtractor) getQuerySpan(ctx context.Context, stmt string) (*ba
}
return &base.QuerySpan{
+ Type: base.Select,
Results: querySpanResult,
SourceColumns: accessTables,
}, nil
diff --git a/backend/plugin/parser/bigquery/test-data/query-span/standard.yaml b/backend/plugin/parser/bigquery/test-data/query-span/standard.yaml
index e1ab6e9378..8260539526 100644
--- a/backend/plugin/parser/bigquery/test-data/query-span/standard.yaml
+++ b/backend/plugin/parser/bigquery/test-data/query-span/standard.yaml
@@ -24,7 +24,7 @@
]
}
querySpan:
- type: 0
+ type: 1
results:
- name: NAME
sourcecolumns:
@@ -80,7 +80,7 @@
]
}
querySpan:
- type: 0
+ type: 1
results:
- name: ID
sourcecolumns:
@@ -174,7 +174,7 @@
]
}
querySpan:
- type: 0
+ type: 1
results:
- name: ID
sourcecolumns:
@@ -263,7 +263,7 @@
]
}
querySpan:
- type: 0
+ type: 1
results:
- name: ID
sourcecolumns:
@@ -349,7 +349,7 @@
]
}
querySpan:
- type: 0
+ type: 1
results:
- name: ID
sourcecolumns:
@@ -428,7 +428,7 @@
]
}
querySpan:
- type: 0
+ type: 1
results:
- name: C1
sourcecolumns:
@@ -523,7 +523,7 @@
]
}
querySpan:
- type: 0
+ type: 1
results:
- name: ID
sourcecolumns:
@@ -600,7 +600,7 @@
]
}
querySpan:
- type: 0
+ type: 1
results:
- name: CITY
sourcecolumns:
@@ -655,7 +655,7 @@
]
}
querySpan:
- type: 0
+ type: 1
results:
- name: ""
sourcecolumns: []
@@ -705,7 +705,7 @@
]
}
querySpan:
- type: 0
+ type: 1
results:
- name: ID
sourcecolumns:
@@ -775,7 +775,7 @@
]
}
querySpan:
- type: 0
+ type: 1
results:
- name: ID
sourcecolumns:
@@ -830,7 +830,7 @@
]
}
querySpan:
- type: 0
+ type: 1
results:
- name: ID
sourcecolumns:
@@ -885,7 +885,7 @@
]
}
querySpan:
- type: 0
+ type: 1
results:
- name: ID
sourcecolumns:
@@ -960,7 +960,7 @@
]
}
querySpan:
- type: 0
+ type: 1
results:
- name: ID
sourcecolumns: