googleapis / googleapis/google-cloud-go

spannertest: not failing as expected on queries with ambiguous column names

Open
#3,651 1 comment 0 reactions 0 assignees View on GitHub
api: spanner priority: p3 type: feature request
Dominant language
Go
Stars
4.5k
Forks
1.6k
Avg merge
1d 13h
Merged PRs (30d)
109

Description

**Client**

spannertest

**Environment**

WSL Ubuntu

**Go Environment**

$ go version
go version go1.15.7 linux/amd64
$ go env

```
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/liza/.cache/go-build"
GOENV="/home/liza/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/liza/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/liza/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/bin/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/bin/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/d/git/src/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build043684261=/tmp/go-build -gno-record-gcc-switches"
```

**Code**

Rough example for purpose of this issue:

```ddl
CREATE TABLE NeighborhoodCats(
CatID INT64 NOT NULL,
CatName STRING(512) NOT NULL,
FavoriteFood String(512) NOT NULL,
) PRIMARY KEY(CatID);

CREATE TABLE HumanCatRelationships(
HumanID STRING(512) NOT NULL,
CatID INT64 NOT NULL,
) PRIMARY KEY(HumanID, CatID);
```

Query:

```sql
SELECT CatID, CatName, FavoriteFood
FROM HumanCatRelationships AS R INNER JOIN NeighborhoodCats AS C
ON R.CatID = C.CatID
WHERE HumanID = @humanID AND CatName = @catName
```

**Expected behavior**

I would expect the result of the above run against a live cloud spanner DB and against spannertest to be the same.

**Actual behavior**

spannertest runs the query above with no reported SQL errors whereas live spanner flags an ambiguous column:

`Column name CatID is ambiguous`

In this case this is a bit counterintuitive as CatID will have the same value as a result of the query, but the column name IS ambiguous and the query would be fixed with `SELECT R.CatID...`

Ideally, spannertest will fail on the same SQL errors as the live DB to ensure consistent behaviour during testing.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.