Skip to content
Snippets Groups Projects
Verified Commit a216d170 authored by Denis Smirnov's avatar Denis Smirnov
Browse files

refactoring: insert redistribution

Previosly we had a very complicated logic for INSERT operator:
we always generated a motion node under INSERT and generated
bucket_id with a special motion command in this virtual table.
As a side effect we made motions even for those INSERTs that was
possible to execute locally.

Another problem was caused by the column type derivation in
INSERT .. VALUES .. expressions. If any column in the first row
contained NULL it confuses Tarantool and it returns scalar (or
even boolean!) type instead. And there is no projection type cast
in Tarantool's insertion. As a result we often had type mismatch
errors in INSERT .. VALUES .. queries.

The solution is to rewrite this weird logic from the scratch.
Now we rewrite the tree somehow like this:

insert into t1 (a, b) values (1, 2)

=>

insert into t1 (a, b, bucket_id)
select
  COL_1,
  COL_2,
  bucket_id(
    coalesce(cast(COL_2 as string), '')
    || coalesce(cast(COL_1 as string), '')
  )
from (
  select
    cast(COLUMN_1 as integer) as COL_1,
    cast(COLUMN_2 as unsigned) as COL_2
  from (values (1, 2))
)
parent 09c2374b
No related branches found
No related tags found
1 merge request!1414sbroad import
Showing
with 545 additions and 495 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment