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

(incorrect) MAL loop instead of manifold triggered by simple change in target list #3955

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments

Comments

@monetdb-team
Copy link

@monetdb-team monetdb-team commented Nov 30, 2020

Date: 2016-03-15 15:08:00 +0100
From: @swingbit
To: SQL devs <>
Version: 11.19.9 (Oct2014-SP2)
CC: @njnes

Last updated: 2016-03-25 09:59:45 +0100

Comment 21910

Date: 2016-03-15 15:08:00 +0100
From: @swingbit

User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36
Build Identifier:

This query was automatically generated, hence a bit verbose. I simplified it manually as much as I could:

-- START QUERY
start transaction;

create table input_double (a1 string, a2 double, prob double);
INSERT INTO input_double VALUES ('latitude',52.0,1.0);
INSERT INTO input_double VALUES ('longitude',5.1,1.0);

CREATE TABLE v(a1 int, a2 point, prob double);
insert into v values(0,sys.point(50,4),1);
insert into v values(1,sys.point(51,5),1);
insert into v values(2,sys.point(52,6),1);

CREATE VIEW p AS
SELECT sys.point(a1,a2) AS a1, prob AS prob
FROM (
SELECT tmp_2.a2 AS a1, tmp_3.a2 AS a2, tmp_2.prob * tmp_3.prob AS prob
FROM
(SELECT a2, prob FROM input_double WHERE a1 = 'latitude') AS tmp_2,
(SELECT a2, prob FROM input_double WHERE a1 = 'longitude') AS tmp_3
) AS tmp;

CREATE VIEW r AS
SELECT a1 AS a1, sys.distance(a2,a3) AS prob
FROM (
SELECT v.a1 AS a1, v.a2 AS a2, p.a1 AS a3, v.prob * p.prob AS prob
FROM v,p
) AS tmp;

explain select * from r;
-- END QUERY

As it is, this generates a MAL loop for the call sys.distance(point,point):

| barrier (X_98,X_99) := iterator.new(X_40);
| X_101 := algebra.fetch(X_35,X_98);
| X_103 := geom.Distance(X_99,X_101);
| bat.append(X_94,X_103);
| redo (X_98,X_99) := iterator.next(X_40);
| exit (X_98,X_99);

Two problems:

Problem 1)
The manifold version is not generated as it should.
However, the manifold version IS generated when I make this simple change (don't ask me why!)
from:
CREATE VIEW r AS
SELECT a1 AS a1, sys.distance(a2,a3) AS prob
to:
CREATE VIEW r AS
SELECT a1 AS a1, prob * sys.distance(a2,a3) AS prob

Problem 2)
The loop as it is appears to be wrong.
The explain shows
"TypeException:user.s430_1[53]:'geom.Distance' undefined in: geom.Distance(X_99:wkb,X_101:int);"

Which means the loop is fetching integer values rather than point values.

Reproducible: Always

$ mserver5 --version
MonetDB 5 server v11.21.14 (64-bit, 64-bit oids, 128-bit integers)
This is an unreleased version
Copyright (c) 1993-July 2008 CWI
Copyright (c) August 2008-2015 MonetDB B.V., all rights reserved
Visit http://www.monetdb.org/ for further information
Found 15.6GiB available memory, 8 available cpu cores
Libraries:
libpcre: 8.38 2015-11-23 (compiled with 8.37)
openssl: OpenSSL 1.0.1k 8 Jan 2015 (compiled with OpenSSL 1.0.1k-fips 8 Jan 2015)
libxml2: 2.9.3 (compiled with 2.9.3)
Compiled by: roberto@photon.hq.spinque.com (x86_64-unknown-linux-gnu)
Compilation: gcc -O3 -pipe -Werror -Wall -Wextra -W -Werror-implicit-function-declaration -Wpointer-arith -Wdeclaration-after-statement -Wundef -Wformat=2 -Wno-format-nonliteral -Winit-self -Winvalid-pch -Wmissing-declarations -Wmissing-format-attribute -Wmissing-prototypes -Wold-style-definition -Wpacked -Wunknown-pragmas -Wvariadic-macros -fstack-protector-all -Wstack-protector -Wpacked-bitfield-compat -Wsync-nand -Wjump-misses-init -Wmissing-include-dirs -Wlogical-op -Wunreachable-code -D_FORTIFY_SOURCE=2
Linking : /usr/bin/ld -m elf_x86_64

Comment 21914

Date: 2016-03-16 13:33:16 +0100
From: @njnes

The merge_project rewriter, rewrote the projections incorrectly, ie it mapped the second argument of the distance call to the v.a1 value (an int). This caused all the problems you indicated. Ie function unknown -> no manifold. etc.

Comment 21915

Date: 2016-03-16 14:14:36 +0100
From: MonetDB Mercurial Repository <>

Changeset eb4112071e54 made by Niels Nes niels@cwi.nl in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=eb4112071e54

Changeset description:

fixes for bug #3955, ie make sure we don't rewrite projections when a name
conflict can occure, because of the rewrite.

Comment 21974

Date: 2016-03-25 09:59:45 +0100
From: @sjoerdmullender

Jul2015-SP3 has been released.

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

Successfully merging a pull request may close this issue.

None yet
1 participant