Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashing on query with interface is nil, not internal.Value #86

Open
colincadams opened this issue Feb 7, 2023 · 4 comments
Open

Crashing on query with interface is nil, not internal.Value #86

colincadams opened this issue Feb 7, 2023 · 4 comments

Comments

@colincadams
Copy link
Contributor

I am using https://github.com/goccy/bigquery-emulator for some tests and it is crashing on a large query I'm sending it. It looks like it has something to do with how it is parsing the partition in the window clause?

I'm using the latest version of the emulator (v0.2.12) which looks to be using v0.13.3 of this repo. I've pasted the stack trace below, if it isn't clear enough from this alone, I can try to trim the current query down to a more minimal case that reproduces the error.

panic: interface conversion: interface is nil, not internal.Value

goroutine 1636 [running]:
github.com/goccy/go-zetasqlite/internal.parseWindowOptions({0xc000d6da40, 0x4, 0xc0003fcc60?})
	/go/pkg/mod/github.com/goccy/go-zetasqlite@v0.13.3/internal/function_window_option.go:317 +0x539
github.com/goccy/go-zetasqlite/internal.(*WindowAggregator).Step(0xc000f77c20, {0xc0007265f0?, 0x1?, 0x46b619?})
	/go/pkg/mod/github.com/goccy/go-zetasqlite@v0.13.3/internal/function_bind.go:139 +0x58
reflect.Value.call({0x2b91260?, 0xc000f77c20?, 0x1?}, {0x2e121f5, 0x4}, {0xc001365200, 0x5, 0x310fea8?})
	/usr/local/go/src/reflect/value.go:556 +0x845
reflect.Value.Call({0x2b91260?, 0xc000f77c20?, 0x5?}, {0xc001365200, 0x5, 0x8})
	/usr/local/go/src/reflect/value.go:339 +0xbf
github.com/mattn/go-sqlite3.(*aggInfo).Step(0xc000412e60, 0xc00001aa80?, {0x7fe6804ac208, 0x5, 0x5})
	/go/pkg/mod/github.com/mattn/go-sqlite3@v1.14.14/sqlite3.go:466 +0xec
github.com/mattn/go-sqlite3.stepTrampoline(0x0?, 0x40dc86?, 0x7fe6804ac208)
	/go/pkg/mod/github.com/mattn/go-sqlite3@v1.14.14/callback.go:46 +0x6b
github.com/mattn/go-sqlite3._Cfunc__sqlite3_step_row_internal(0x7fe6cc029cc8, 0xc0009aa320, 0xc0009aa328)
	_cgo_gotypes.go:370 +0x4c
github.com/mattn/go-sqlite3.(*SQLiteStmt).execSync.func3(0xc0011a6090?, 0x4cc65f8?, 0x0?)
	/go/pkg/mod/github.com/mattn/go-sqlite3@v1.14.14/sqlite3.go:2082 +0x65
github.com/mattn/go-sqlite3.(*SQLiteStmt).execSync(0xc0011a6090, {0x4cc65f8?, 0xc000bdc7d0?, 0x448025?})
	/go/pkg/mod/github.com/mattn/go-sqlite3@v1.14.14/sqlite3.go:2082 +0x65
github.com/mattn/go-sqlite3.(*SQLiteStmt).exec.func1()
	/go/pkg/mod/github.com/mattn/go-sqlite3@v1.14.14/sqlite3.go:2053 +0x32
created by github.com/mattn/go-sqlite3.(*SQLiteStmt).exec
	/go/pkg/mod/github.com/mattn/go-sqlite3@v1.14.14/sqlite3.go:2052 +0x11b
@goccy
Copy link
Owner

goccy commented Feb 17, 2023

@colincadams Thank you for your report.

Looking at the stack trace, it does not seem to matter that the query string is long 🤔 .
Please provide minimum reproduction code.

@szymon-blaszczyk-db
Copy link

szymon-blaszczyk-db commented Dec 18, 2023

Hello! Having suffered the same sort of error, I can try to help the manner out providing an equivalent of the query I had used:

2023-12-18 10:36:12 2023-12-18T09:36:12.037Z INFO server/middleware.go:63 POST /bigquery/v2/projects/integration/jobs {"query": "prettyPrint=false"}
2023-12-18 10:36:12 2023-12-18T09:36:12.045Z INFO contentdata/repository.go:167 {"query": "SELECT\n t.id,\n t.date,\n t.detail,\n t.type,\n t.latest_load_time,\nFROM (\n SELECT\n *,\n ROW_NUMBER() OVER (PARTITION BY id, date, detail ORDER BY latest_load_time DESC) AS ranked_order\n FROM\n dataset.table\n) t\nWHERE\n t.type = 'A'\n AND t.detail != "P"\n AND (t.latest_load_time BETWEEN @lower_dts\n AND @upper_dts)\n AND t.ranked_order = 1", "values": [{"Name":"lower_dts","Value":"2023-12-07 14:44:00.000000+00:00"},{"Name":"upper_dts","Value":"2023-12-18 09:36:11.960152+00:00"}]}
2023-12-18 10:36:12 panic: interface conversion: interface is nil, not internal.Value

I have made multiple attempts at adjusting the query, especially with regard to the windowing function. I had used unnamed windows (like in the example above) as well as named ones, tried defining the PARTITION within a named definition but ORDER in SELECT statement... No known syntax for working with the window function seems to work.

The query is being passed into the emulator being read from an .sql file, content of which is handed to the com.google.cloud.bigquery.BigQuery.create(JobInfo jobInfo) method (via wrapping with com.google.cloud.bigquery.QueryJobConfiguration.Builder).

@goccy FYI

@ohaibbq
Copy link
Contributor

ohaibbq commented Jan 29, 2024

@szymon-blaszczyk-db @goccy I've identified the root cause of this to #140 and opened a fix in #141

@ohaibbq
Copy link
Contributor

ohaibbq commented Mar 9, 2024

This will be fixed with #169

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants