Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Panic on query using EXPLODE #755

Closed
juanjux opened this issue Jun 20, 2019 · 3 comments · Fixed by #757 or #765
Closed

Panic on query using EXPLODE #755

juanjux opened this issue Jun 20, 2019 · 3 comments · Fixed by #757 or #765
Assignees
Labels
bug Something isn't working

Comments

@juanjux
Copy link
Contributor

juanjux commented Jun 20, 2019

Adding it here because I think it's related to explode.

The query:

SELECT
    EXPLODE(UAST_EXTRACT(UAST(f.blob_content, 'Go', '//uast:Import/Path'), 'Value')) 
FROM files as f
WHERE f.file_path REGEXP('.*.go$')
    AND f.file_path NOT REGEXP '^vendor.*'
    AND NOT IS_BINARY(f.blob_content)
    AND f.blob_size < 1000000
LIMIT 1;

Causes this panic:

ERRO[0703] mysql_server caught panic:
unresolved column is a placeholder node, but IsNullable was called
/home/juanjux/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190619104848-eaab1795353a/sql/expression/unresolved.go:41 (0x9e7148)
	com/src-d/go-mysql-server/sql/expression.(*UnresolvedColumn).IsNullable: panic("unresolved column is a placeholder node, but IsNullable was called")
/home/juanjux/sourced/gitbase/internal/function/uast.go:68 (0xea4bb7)
	com/src-d/gitbase/internal/function.(*uastFunc).IsNullable: return u.Blob.IsNullable() || u.Mode.IsNullable() ||
/home/juanjux/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190619104848-eaab1795353a/sql/expression/common.go:55 (0x9dbc82)
	com/src-d/go-mysql-server/sql/expression.(*BinaryExpression).IsNullable: return p.Left.IsNullable() || p.Right.IsNullable()
/home/juanjux/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190619104848-eaab1795353a/sql/expression/function/explode.go:71 (0xcdd2a2)
	com/src-d/go-mysql-server/sql/expression/function.(*Generate).IsNullable: func (e *Generate) IsNullable() bool { return e.Child.IsNullable() }
/home/juanjux/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190619104848-eaab1795353a/sql/analyzer/resolve_generators.go:47 (0xd1e410)
	com/src-d/go-mysql-server/sql/analyzer.resolveGenerators.func1: expression.NewGetField(g.idx, g.expr.Type(), name, g.expr.IsNullable()),
/home/juanjux/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190619104848-eaab1795353a/sql/plan/project.go:78 (0xa08d89)
	com/src-d/go-mysql-server/sql/plan.(*Project).TransformUp: return f(NewProject(p.Projections, child))
/home/juanjux/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190619104848-eaab1795353a/sql/plan/limit.go:45 (0xa047e0)
	com/src-d/go-mysql-server/sql/plan.(*Limit).TransformUp: child, err := l.Child.TransformUp(f)
/home/juanjux/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190619104848-eaab1795353a/sql/analyzer/resolve_generators.go:17 (0xd0bf6c)
	com/src-d/go-mysql-server/sql/analyzer.resolveGenerators: return n.TransformUp(func(n sql.Node) (sql.Node, error) {
/home/juanjux/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190619104848-eaab1795353a/sql/analyzer/batch.go:67 (0xd01497)
	com/src-d/go-mysql-server/sql/analyzer.(*Batch).evalOnce: result, err = rule.Apply(ctx, a, result)
/home/juanjux/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190619104848-eaab1795353a/sql/analyzer/batch.go:38 (0xd0114e)
	com/src-d/go-mysql-server/sql/analyzer.(*Batch).Eval: cur, err := b.evalOnce(ctx, a, n)
/home/juanjux/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190619104848-eaab1795353a/sql/analyzer/analyzer.go:171 (0xcf96b3)
	com/src-d/go-mysql-server/sql/analyzer.(*Analyzer).Analyze: prev, err = batch.Eval(ctx, a, prev)
/home/juanjux/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190619104848-eaab1795353a/engine.go:143 (0xd3a00c)
	com/src-d/go-mysql-server.(*Engine).Query: analyzed, err = e.Analyzer.Analyze(ctx, parsed)
/home/juanjux/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190619104848-eaab1795353a/server/handler.go:90 (0xd3bcc5)
	com/src-d/go-mysql-server/server.(*Handler).ComQuery: schema, rows, err := h.e.Query(ctx, query)
/home/juanjux/go/pkg/mod/vitess.io/vitess@v3.0.0-rc.3.0.20190602171040-12bfde34629c+incompatible/go/mysql/conn.go:819 (0xc3b327)
	io/vitess/go/mysql.(*Conn).execQuery: err := handler.ComQuery(c, query, func(qr *sqltypes.Result) error {
/home/juanjux/go/pkg/mod/vitess.io/vitess@v3.0.0-rc.3.0.20190602171040-12bfde34629c+incompatible/go/mysql/conn.go:749 (0xc3ad41)
	io/vitess/go/mysql.(*Conn).handleNextCommand: if err := c.execQuery(sql, handler, more); err != nil {
/home/juanjux/go/pkg/mod/vitess.io/vitess@v3.0.0-rc.3.0.20190602171040-12bfde34629c+incompatible/go/mysql/server.go:441 (0xc4ba65)
	io/vitess/go/mysql.(*Listener).handle: err := c.handleNextCommand(l.handler)
/usr/lib/go-1.12/src/runtime/asm_amd64.s:1337 (0x45a1c0)
	goexit: BYTE	$0x90	// NOP 

Removing the EXPLODE makes it work, retuning an empty array.

Curiously I tried forcing an empty array with SELECT EXPLODE(SPLIT("", "")) (which inner SPLIT also returns an empty array) and then it works.

@juanjux juanjux added the bug Something isn't working label Jun 20, 2019
@erizocosmico erizocosmico self-assigned this Jun 20, 2019
@eiso
Copy link
Member

eiso commented Jun 22, 2019

Thank you for fixing this!

@eiso
Copy link
Member

eiso commented Jun 22, 2019

Unfortunately I still get this error after upgrading to release 0.22.0-rc1, which ships the PR #757

time="2019-06-22T02:05:28Z" level=debug msg="executing query" query="SELECT\n    EXPLODE(UAST_EXTRACT(UAST(f.blob_content, 'Go', '//uast:Import/Path'), 'Name'))\nFROM files as f\nWHERE f.file_path REGEXP('.*.go$')\n    AND f.file_path NOT REGEXP '^vendor.*'\n    AND NOT IS_BINARY(f.blob_content)\n    AND f.blob_size < 1000000\nLIMIT 1"
time="2019-06-22T02:05:28Z" level=info msg="audit trail" action=authorization address="172.18.0.8:54250" connection_id=18 permission=read pid=100 query="SELECT\n    EXPLODE(UAST_EXTRACT(UAST(f.blob_content, 'Go', '//uast:Import/Path'), 'Name'))\nFROM files as f\nWHERE f.file_path REGEXP('.*.go$')\n    AND f.file_path NOT REGEXP '^vendor.*'\n    AND NOT IS_BINARY(f.blob_content)\n    AND f.blob_size < 1000000\nLIMIT 1" success=true system=audit user=root
time="2019-06-22T02:05:28Z" level=info msg="ConnectionClosed: client 18"
time="2019-06-22T02:05:28Z" level=error msg="mysql_server caught panic:\nunresolved column is a placeholder node, but IsNullable was called\n/usr/local/go/src/runtime/panic.go:513 (0x42bdc8)\n/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190621085943-683a87204be3/sql/expression/unresolved.go:41 (0x9b8d28)\n/go/src/github.com/src-d/gitbase/internal/function/uast.go:68 (0xe73997)\n/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190621085943-683a87204be3/sql/expression/common.go:55 (0x9ad902)\n/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190621085943-683a87204be3/sql/expression/function/explode.go:71 (0xca6012)\n/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190621085943-683a87204be3/sql/analyzer/resolve_generators.go:47 (0xce735f)\n/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190621085943-683a87204be3/sql/plan/project.go:78 (0x9db3f8)\n/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190621085943-683a87204be3/sql/plan/limit.go:45 (0x9d6c10)\n/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190621085943-683a87204be3/sql/analyzer/resolve_generators.go:17 (0xcd4f5c)\n/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190621085943-683a87204be3/sql/analyzer/batch.go:67 (0xcca767)\n/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190621085943-683a87204be3/sql/analyzer/batch.go:38 (0xcca40e)\n/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190621085943-683a87204be3/sql/analyzer/analyzer.go:171 (0xcc2b1b)\n/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190621085943-683a87204be3/engine.go:143 (0xd033bc)\n/go/pkg/mod/github.com/src-d/go-mysql-server@v0.4.1-0.20190621085943-683a87204be3/server/handler.go:90 (0xd05058)\n/go/pkg/mod/vitess.io/vitess@v3.0.0-rc.3.0.20190602171040-12bfde34629c+incompatible/go/mysql/conn.go:819 (0xc079d7)\n/go/pkg/mod/vitess.io/vitess@v3.0.0-rc.3.0.20190602171040-12bfde34629c+incompatible/go/mysql/conn.go:749 (0xc073e9)\n/go/pkg/mod/vitess.io/vitess@v3.0.0-rc.3.0.20190602171040-12bfde34629c+incompatible/go/mysql/server.go:441 (0xc1741b)\n/usr/local/go/src/runtime/asm_amd64.s:1333 (0x459690)\n"

@ajnavarro
Copy link
Contributor

Working, but with other XPATH expression, the imports one is returning no results:

mysql> SELECT file_path,        explode(uast_extract(uast(blob_content, LANGUAGE(file_path, blob_content), '//uast:Identifier'), "Name")) name FROM commit_files NATURAL JOIN refs NATURAL JOIN blobs WHERE ref_name='HEAD' AND LANGUAGE(file_path,blob_content) = 'Go' limit 10;
+----------------+---------+
| file_path      | name    |
+----------------+---------+
| asset.go       | Asset   |
| asset.go       | Path    |
| asset.go       | string  |
| asset.go       | Name    |
| asset.go       | string  |
| asset.go       | Func    |
| asset.go       | string  |
| asset.go       | bindata |
| driver/main.go | fmt     |
| driver/main.go | os      |
+----------------+---------+
10 rows in set (0.02 sec)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
4 participants