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

exec: mixed type binary expressions and comparisons #39189

Closed
6 tasks done
rafiss opened this issue Jul 31, 2019 · 0 comments · Fixed by #40272
Closed
6 tasks done

exec: mixed type binary expressions and comparisons #39189

rafiss opened this issue Jul 31, 2019 · 0 comments · Fixed by #40272
Assignees
Labels
A-sql-vec SQL vectorized engine

Comments

@rafiss
Copy link
Collaborator

rafiss commented Jul 31, 2019

We need to handle mixed types in projection ops. For example:

root@127.0.0.1:60323/defaultdb> create table foo (a int4 primary key);
CREATE TABLE

root@127.0.0.1:60323/defaultdb> insert into foo values(1);
INSERT 1

root@127.0.0.1:60323/defaultdb> select a+1 from foo;
   ?column?
+------------+
  2
(1 row)

root@127.0.0.1:60323/defaultdb> set experimental_vectorize=always;
SET

root@127.0.0.1:60323/?> select a+1 from foo;
pq: unable to vectorize execution plan: unable to columnarize render expression "@1 + 1:::INT8": BinaryExpr on int4 and int is unhandled

There are a few different types of mixed type expressions to cover. We should probably implement them in this order:

  • Comparison expressions. Only allow floats to be compared to to other float types, and ints to be compared to all other int types
  • Allow all the mixed type comparisons, like int-float, int-decimal, etc.
  • Binary expressions for plus, minus, and multiplication. Again, only mixed types should be float-float or int-int.
  • All the mixed type expressions for plus, minus, and mult. (Might be easier to do at same time as above?)
  • Binary expression for division. NOTE: currently the overloads do not implement the floor division // operator. start with that. (floor division work will be covered by exec: support //, %, and bitwise binary operators #40312)
  • Then afterwards handle regular division with the / operator, which is not really done correctly right now.

Also, sometimes CastExpr is planned, and we will handle that in #39372

@rafiss rafiss added the A-sql-vec SQL vectorized engine label Jul 31, 2019
@rafiss rafiss self-assigned this Jul 31, 2019
rafiss added a commit to rafiss/cockroach that referenced this issue Aug 8, 2019
This adds support for int-int comparisons and float-float comparisons
(of different sizes), as well as various string comparisons. This
is necessary to support TPC-H queries 7, 16, 19, and 21 (though there
are still other issues to address before those are fully supported).

There is some refactoring here so that as a next step we can support
comparisons between different types entirely (e.g. int-decimal).

touches cockroachdb#39189

Release note: None
rafiss added a commit to rafiss/cockroach that referenced this issue Aug 14, 2019
This adds support for int-int comparisons and float-float comparisons
(of different sizes), as well as various string comparisons. This
is necessary to support TPC-H queries 7, 16, 19, and 21 (though there
are still other issues to address before those are fully supported).

There is some refactoring here so that as a next step we can support
comparisons between different types entirely (e.g. int-decimal).

touches cockroachdb#39189

Release note: None
rafiss added a commit to rafiss/cockroach that referenced this issue Aug 15, 2019
This adds support for int-int comparisons and float-float comparisons
(of different sizes), as well as various string comparisons. This
is necessary to support TPC-H queries 7, 16, 19, and 21 (though there
are still other issues to address before those are fully supported).

There is some refactoring here so that as a next step we can support
comparisons between different types entirely (e.g. int-decimal).

touches cockroachdb#39189

Release note: None
rafiss added a commit to rafiss/cockroach that referenced this issue Aug 15, 2019
This adds support for int-int comparisons and float-float comparisons
(of different sizes), as well as various string comparisons. This
is necessary to support TPC-H queries 7, 16, 19, and 21 (though there
are still other issues to address before those are fully supported).

There is some refactoring here so that as a next step we can support
comparisons between different types entirely (e.g. int-decimal).

touches cockroachdb#39189

Release note: None
craig bot pushed a commit that referenced this issue Aug 16, 2019
39464: exec: handle some mixed type comparison expressions r=rafiss a=rafiss

This adds support for int-int comparisons and float-float comparisons
(of different sizes), as well as various string comparisons. This
is necessary to support TPC-H queries 7, 16, 19, and 21 (though there
are still other issues to address before those are fully supported).

There is some refactoring here so that as a next step we can support
comparisons between different types entirely (e.g. int-decimal).

touches #39189

Release note: None

39472: opt: prune RHS of a semi/anti join r=ridwanmsharif a=ridwanmsharif

Fixes #38704.

This change adds a PruneSemiAntiJoinRightCols to prune
columns in the RHS of a semi/anti join. Alternatively,
we could just tag the PruneJoinRightCols rule as higher
priority to achieve the same effect (previously that rule
was never triggered because the `EliminateProjects` rule
would fire and remove the projections after
`PruneJoinLeftCols` rule is applied). I prefer this rule
because it avoids requiring an ordering of transformations.

Release note: None

Co-authored-by: Rafi Shamim <rafi@cockroachlabs.com>
Co-authored-by: Ridwan Sharif <ridwan@cockroachlabs.com>
@rafiss rafiss changed the title exec: BinaryExpr on int4 and int is unhandled exec: mixed type binary expressions and comparisons Aug 22, 2019
craig bot pushed a commit that referenced this issue Aug 26, 2019
39778: exec: support comparisons between all numeric types r=rafiss a=rafiss

The vectorized engine now supports comparisons between floats, ints, and
decimals.

touches #39189

Release note: None

40197: pgwire: improve multiple portal error msgs r=jordanlewis a=jordanlewis

And relink to new issue (#40195).

Release note: None

40203: builtins: fix bug in aclexplode; add tests r=jordanlewis a=jordanlewis

Closes #39794.

Release note: None

Co-authored-by: Rafi Shamim <rafi@cockroachlabs.com>
Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
@craig craig bot closed this as completed in a4b1670 Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-vec SQL vectorized engine
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant