arijeetmukherjee3108-droid opened a new issue, #41689:
URL: https://github.com/apache/beam/issues/41689
### What happened?
`BigQueryVectorSearchParameters.format_query()` in
`sdks/python/apache_beam/ml/rag/enrichment/bigquery_vector_search.py` generates
invalid BigQuery SQL in two cases:
1. **Invalid `options` clause:** BigQuery's `VECTOR_SEARCH` expects
`options` to be a single-quoted JSON string literal (e.g. `options =>
'{"use_brute_force": true}'`). Currently, `format_query()` interpolates the
Python `dict` directly (`f", options => {self.options}"`), producing invalid
SQL such as:
```sql
, options => {'use_brute_force': True, 'fraction_lists_to_search': 0.01}
```
2. **Duplicate `embedding_column` in subquery:** The base table subquery
unconditionally selects `(SELECT {columns_str}, {self.embedding_column} ...)`.
If `embedding_column` is also included in `columns`, BigQuery receives a
duplicate column name (e.g. `SELECT content, embedding, embedding`).
### Reproduction
```python
from apache_beam.ml.rag.enrichment.bigquery_vector_search import
BigQueryVectorSearchParameters
from apache_beam.ml.rag.types import Content, EmbeddableItem, Embedding
params = BigQueryVectorSearchParameters(
project='my-proj',
table_name='my-proj.ds.tbl',
embedding_column='embedding',
columns=['content', 'embedding'],
neighbor_count=5,
options={'use_brute_force': True, 'fraction_lists_to_search': 0.01},
)
item = EmbeddableItem(
id='1',
content=Content(text='hi'),
embedding=Embedding(dense_embedding=[0.1, 0.2]),
)
print(params.format_query([item]))
```
### Issue Priority
Priority: 2 (default / most bugs should be filed as P2)
### Issue Components
- [x] Component: Python SDK
- [ ] Component: Java SDK
- [ ] Component: Go SDK
- [ ] Component: Typescript SDK
- [ ] Component: IO connector
- [ ] Component: Beam YAML
- [ ] Component: Beam examples
- [ ] Component: Beam playground
- [ ] Component: Beam katas
- [ ] Component: Website
- [ ] Component: Infrastructure
- [ ] Component: Spark Runner
- [ ] Component: Flink Runner
- [ ] Component: Prism Runner
- [ ] Component: Hazelcast Jet Runner
- [ ] Component: Google Cloud Dataflow Runner
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]