Skip to content

Insert succeeds when non-existant columns are provided #421

@pgcamus

Description

@pgcamus

What happened?

Create a table

$ bq \
    --api=http://host.docker.internal:19050/ \
    --project_id=camus-unittest \
    mk \
        -d \
        pg_test
$ bq --api=http://host.docker.internal:19050/ \
    --project_id=camus-unittest \
    query \
        --nouse_legacy_sql \
        "CREATE TABLE pg_test.schema_test (string_field STRING)"
$ bq \
    --api=http://host.docker.internal:19050/ \
    --project_id=camus-unittest \
    show \
        --schema \
        pg_test.schema_test
[{"name":"string_field","type":"STRING"}]

Attempt to insert some rows, one of which references columns which do not exist in the schema

$ cat foo.json 
{"string_field": "YESSIRR"}
{"string_field": "YESSIRR2", "badddd_field": "NOSIR2"}
$ bq \
    --api=http://host.docker.internal:19050/ \
    --project_id=camus-unittest \
    insert \
        pg_test.schema_test \
        ./foo.json
$ bq \
    --api=http://host.docker.internal:19050/ \
    --project_id=camus-unittest \
    query \
        "SELECT * FROM pg_test.schema_test"
+--------------+
| string_field |
+--------------+
| YESSIRR      |
| YESSIRR2     |
+--------------+

What did you expect to happen?

I expected the bq insert to fail, as it does in GCP BigQuery

$ bq \
    --project_id=camus-infra \
    show \
        --schema \
        pg_test.schema_test
[{"name":"string_field","type":"STRING"}]
$ cat foo.json 
{"string_field": "YESSIRR"}
{"string_field": "YESSIRR2", "badddd_field": "NOSIR2"}
$ bq \
    --project_id=camus-infra \
    insert \
        pg_test.schema_test \
        ./foo.json
record 1 errors:        invalid: no such field: badddd_field.
record 0 errors:        stopped: 

How can we reproduce it (as minimally and precisely as possible)?

See above.

Anything else we need to know?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions