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

sql: disallow ordering by VECTOR columns #131703

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions pkg/ccl/logictestccl/testdata/logic_test/vector
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,54 @@ query T
SELECT '[1,2,3]'::VECTOR::FLOAT8[];
----
{1,2,3}


# Regression test for #131573. Spilling vectors to disk is not supported until
# vectors can be key-encoded.
statement ok
CREATE TABLE t131573 (i INT PRIMARY KEY);

statement ok
INSERT INTO t131573 SELECT i FROM generate_series(1, 28) g(i)

statement ok
SET testing_optimizer_disable_rule_probability = 1;

statement ok
SET vectorize = off;

statement error pgcode 0A000 unimplemented: can't order by column type VECTOR
SELECT
tab_1267.tableoid AS col_2423,
'':::VOID AS col_2424,
tab_1270.i AS col_2425,
tab_1268.i AS col_2426,
'7FFFFFFF/FFFFFFFF':::PG_LSN AS col_2427,
'00:01:39.999999+00':::TIMETZ AS col_2428,
'08:20:00-15':::TIMETZ AS col_2429,
'[-3.7953218e+33,-5.132204e+37,8.643205e-05,-5.5844643e+37,-1.5062979e+09,-109825.18,-8.470669e+14,-5.065297e+37,0.0007944686,-1.935601e-32,4.7178306e-30,1.7302921e+13,-1.5352918e+29,-440.40878,-24.41461,7.5978804e-19,1.3399945e+12,-6.415122e+25,-3.8306024e-36,-1.1622e+09,0.05741809,1.8281482e-10,-4.4906845e+29,3.537801e-06,-1.0941364e+31,4.6337483e-37,-6.3735416e+16,2.9026163e-11,1.4279478e-05,-30736.674,-15.1720295,-92997.625,-4.9892673e-17,3.943437e+35,2.3739657e+28,-1.8157058e-34,-1.8640957e+34,1.0429477e-16,1.8380118e+24,9.516706e-20,-1.5673359e+13,-6.563423e-33,-2.7221127e+35,4.3559537e-14,3.0937842e-17,5.411067e-06,-3457.3667,6.7098145e-21,1.5738296e+25,5.464743e-33,4.742004e+32,1.2399716e+17,-6.927317e+31,8.613097e-35,-2.0369262e-09,7978.1553,-1.0569652,-3.6190855e+16,1.8942217e+09,223.39319,4.282288e+11,-4.455049e-34,3.0711986e+13,2.3448091e-19,1.0415503e-10,-2.514382e+13,-1.7847523e-16,2.2985838e+38,-76941.336,3.4084958e-29,5.6421267e+26,-2.4792896e-18,-1.5950682e+06,-4.6028377e-32,-1.0012632e+20,8.0190704e+33,1.0707643e+20,-1.8181548e+36,-0.024483496,1.1570861e+16,-4.9286146e-28,-4.830511e+12,6.4743423e+25,-193.2568,-2.8053132e-21,-4.8112608e+33,9.150063e-09,-4.897617e+29,-4.458953e+11,-2.3225355e+21,16793.512,560.35535,-2.38942e+36,1.5824616e-15,-1.4904108e+37,-3.398902e-13,-5.589114e+23,1.645791e-23,6.790028e+13,-4.7085233e+34,-2.0403363e-37,76768.75,274.68204,-1.2761306e-33,-1.1233329e+12,2.9635564e+22,-6.464023e-27,-1.0067163e-22,7.2886674e+19,-9.809667e-26,3.085786e-05,2.6666428e+10,5.4119246e-14,3.564982e+16,8.437495e-27,-3.350398e-17,-1.9738832e+06,9.1878346e+11,2.8711658e-15,6.0273466e-26,-8.2633627e+34,-43.109715,-1.2696841e-28,-1.4754021e+16,6.6592667e+34,1.3492485e+37,-6.1486147e+09,-13147.241,3.889733e+23,1.1785698e-17,6.35963e+10,-1.5563547e+09,1.7742052e+22,-1.0781451e-20,-3.0875912e-15,2.047337e-05,3.9287744e+12,9.024156e+14,2.7527163e-24,2.9167922e-34,-7.1013315e+29,8.553383e+06,-5.4454533e+37,-5.460633e+31,2.4704255e+38,4.639681e+23,6.488711e-10,-6.000045e+37,-2.564926e+08,3.7243076e-14,1.2564196e+18,1.0420248e+19,8.544853e-17,2.836581e+12,4.1824052e-22,2.5112278e+33,-948024.75,-7.2574536e-13,1.9659253e-11,5.338847e+17,3.494091e-10,2.5995491e+35,1.7883661e-10,-5.6355302e-21,1.216532e+16,-0.007204843,-1.433076e+19,-5.850046e+13,-5.838894e+15,-1.1778454e-18,-623049.6,-2.0026062e+06,-1.8475214e-15,1.2504496e-23,62.900272,1.1521523e+38,-5.308766e+16,-3.4633795e+31,-6451.7617,-1.1287261e+25,-1.0983194e+26,-5.7170433e-05,1.5078498e-16,-2.84017e-06,5.7710134e+27,-1.3965062e-17,-2.2093698e-26,1.4864606e-08,2.923918e+18,1.1202598e-12,-77.75024,-82507.24,1.1250237e+21,0.67796576,-5.6376764e+21,1.2676121e+15,-5.957654e+36,1.8980822e+13,8.59208e-38,9.3113405e+16,-1.4625426e-27,1.3014755e-30,7.2486416e-37,-1.5660787e-30,8.720347e+33,4.017937e+09,-4.2616337e+31,-6.756582e-07,-1.1381526e-25,4.900442e-05,-2.0407465e+21,-1.4567442e+12,2.4160406e-22,3.791572e+06,-1.86996e-28,-6.1457196e+21,-2.1182645e-13,1.3337653e+26,5.4910316e-11,2060.8503,2.0973548e-17,-4.6391134e+22,1.476911e-12,-488.8974,3.0376863e+22,9.002644e-37,-3.2174322e-16,-1.4868072e-36,-0.17597519,3659.0933,-4.0045275e+06,0.03646259,3.0470872e+07,-6.335876e-16,2.9007228e-24,-5.9010312e-33,2.0987492e-29,-1.5501779e+23,2.768132e+37,0.00013575754,1.4029743e-27,-2.6666478e+23,1.0266367e-08,-1.2672312e+10,5.5922037e-37,-2.756151e+36,-2.3175286e+07,5.8063146e-26,-4.0962927e-35,2.5199631e-36,2.069457e-33,3.0273584e+16,-1.00249165e+09,3.891235e-37,-2.7843372e-24,-6.884407e-32,-3.418991e-27,-1.0212043e-13,4.3047913e-21,-5.1385838e+22,251.46916,13.621713,-1.883852e-39,-5.2081044e-19,-5.850147e-29,-1.8854126e+24,4.9108495e+09,-4.752312e-08,-3.9734836e+14,9.480267e-35,-0.0004215252,2.7304673e-36,129.05515,1.0688073e+09,6.2734783e+22,39.405483,1.3835738e-14,-4.2016085e-22,-3.220992e-20,-1.9369886e+08,2.880144e-31,-1.2339889e+29,1.7934438e-08,-1.920243e-11,7.242663e+13,-1.8044662e+07,40.39524,-1.5240464e-24,1.1195584e+32,-1.982625e-32,8.2641864e-23,-7.6615555e+11,3.0511376e-35,-1.2762896e-09,-6.76299e+27,-1.729689e-14,217521.05,-0.02738627,-1.5403666e-19,-5.281041e-22,1.536378e+11,-6.653482e+31,-1.3921715e+16,-7.479822e-36,-9.44529e-33,-5.593911e-38,8.0421836e+27,-5.0726326e-26,1.4188586e-24,6.772245e-20,-1.713283e+29,3.5244818e-09,1.4323528e+34,55495.754,1.7534775e-10,4.045299e+28,1.6577702e+31,1.0389167e-25,-2.302825e-29,1.3867399e+20,8.3865123e-19,-3.4862794e+15,-2.3806593e+27,92.90648,2.0451075e-19,-10697.025,0.00017972982,-2.2508e-18,2.4414017e-16,6.6043654e-37,3.5947036e+32,-6.4228774e+18,8.9882374e-29,2.6510888e+38,-2.0488528e-25,-4.443434e+13,4.7289906e+24,-3.797532e-07,-3.4343356e+35,-0.0032492129,-2.2750546e-13,-0.026936822,1.8559319e+21,9.348411e-12,-1.9947207e+16,1.8648463e-32,1.4204564e+17,2.6983448e+17,-1.6891995e+13,-3.2688988e+28,-0.12070139,-1.4147686e+33,4.2008543e-35,6.968667e-21,2.3428138e-30,-5.2267307e+29,-6.868594e+07,-1.8651484e+07,-1.5931777e+10,-946.4799,-3.4726954e+34,7.0762447e+37,3.6545273e-31,-5.284129e-29,-8.569975e+08,640560.06,3.7043995e-38,7.833057e+37,1.4600545e+33,-8.768011e-08,1.3266601e+09,-6.8505573e+22,-15.403488,-1.5956196e-06,-6.54356e-30,-1.02519274e+30,3.5564082e+25,1.9399208e+20,-3.1152592e+21,-2.990979e-07,6.5915062e+35,5.3255477e+14,-0.0329434,-1.8795123e+08,52472.766,-5.9110423e+13,-1.0975374e+21,5.784986e+15,9.838462e+21,-6.4253167e+15,1.6471021e-22,-2.0772504e+11,1.1726693e+22,7.984032e-19,-26.909626,-2.6589122e-15,-3.8284003e+08,0.0045672064,2.9600098e+23,4.5668394e+24,-1.3424586e-38,-1.7341201,1.6980739,4.3151897e+26,-2.1520144e+30,-4.1325616e-06,2.2170992e+33,0.08554908,1.4993741e-33,8.860964e+36,-2.606888e-34,-5.1376295e-18,-1.4655806e+23,2.8483984e+25,-9.353467e-10,2.060378e+35,1.2513963e-23,2.708087e+08,-2.315721e+37,-7.073455e-20,3.5662713e-25,-0.0004374388,-4.7116692e+26,4.3486036e-08,-1.2380057e-21,1.2689992e+27,-4.4352305e+24,-6.0076855e-36,4.036063e+30,5.129419e-05,-4.9297125e+35,-1.8263556e+32,1.06695314e-16,1.1371234e-07,-2.7622738e-26,7.860948e+18,-5.164729e-33,-6.8420556e+27,0.047708467,-1.2493382e-15,0.0016946044,6.2957683e+12,-3.835634e-19,-2.8190265e-26,1.8815904e+16,-5.6850326e+37,-1.3585531e+18,-1.2043385e+35,1.7582509e+37,-4.074372e+26,4388.1016,-1.3129469e-16,-0.17418139,-1.3955145e+15,1.025192e-23,4.4919533e-20,2.999707e+06,-5.661283e+13,-2.9311642e+31,-1.0207146e-36,0.09710074,-2.510124e-39,1.8389194e-25,5.582102e+23,5.82381e-32,1.00366065e-20,-81.54572,-5.6882147e-08,-4.871062e+32,7.1902417e-17,-1.7665657e+25,6.0506687e-16,5.7406624e-32,-2.8152716e-31,0.002797209,3.8215326e-25,0.048571896,2.691484e-17,-17.055586,-1.05655084e+37,1.7588232e+23,3.7755322e-17,8.626068e-29,2.610609e-30,1.5786047e+29,-0.0006587603,2.0113787e-14,8.321141e+31,-0.015216283,-3.541038e+31,3.2162145e-18,-1.02071985e-14,2.3421431e-26,-2.668081e+36,-1.4589297e-06,1.868287e-36,-5.470929e+16,-7.027929e+13,-0.0008752376,5.531114e-15,-1.3570338e-35,5.4769347e-31,-2.723929e+19,1.0104035e-20,3.3409315e+21,2.4965858e+20,-1.4677834e+16,5.7579854e+19,3.0096203e+31,-1.4856763e+23,2.597699e+06,-3.774769e-34,8.651645e+22,1.3949847e+13,-8.604807e-28,-4.5411778e+30,-8.039499e-29,7.2752946e-16,-9.541059e+17,6.438951e-32,9.58529e-36,2.2881372e-14,-0.05989417,3.72053e+36,-1.129754e+06,1.5292207,3.2394195e+33,1.5827384e+12,-1.6197216e-12,-3.1613155e+20,-7.465628e+35,9.67747e-13,2.5660454e-15,7.944382e-07,4.1139117e+17,-2.846388e+13,-4.2380179e-38,7.768298e-23,-2.6463257e+36,-4.9616638e-08,2.0893201e-29,4.2786035e+09,5.80829e-06,0.005540639,8.096768e+16,-1.4149712e+15,-7.26909e-12,1.1000944e-15,-9.529723e+25,-253088.1,-0.19737001,-5.7653776e+07,4748.8325,-9.3970937e-29,-1.6437117e+10,-3.4559856e+22,1.3083369e-33,-4.530681e+21,5.881438e+29,-5.1332367e-17,-6.445082e-05,-4.881849e+29,1.2105203e-07,1.0139912e-05,1.9522667e+38,4.14817e+22,2.285429e-12,-7.614719e-36,-3520.2324,-3.9126662e-32,-1.1944447e-14,9.502196e-32,5.640967e-30,3.800094e+15,8.412837e-09,6.809022e+37,0.027446764,-5.124653e+22,-5.1737387e-16,-4.34733e-31,4.5941865e-28,-3.8557368e-07,1.589282e-26,9.389605e-16,-9.321852e-09,-1.4312983e+20,6.4114545e-05,-6.507192e+15,2.412694e-20,-1.5526455e+26,91010.46,0.009513133,9.885293e-33,1.844294e+24,1.935829e-34,-5.7787837e-11,-1.9909166e+33,-6.402554e-32,1.686892e-34,-1.5138757e+32,-1.3244573e-09,-99723.984,-5.9057593e+21,5.3152423e-11,1.4142437e-13,-1.8911346e+36,-1.1386684e-30,-3.2314103e+12,-5.94996e-19,-2.8397169e-08,-753051.7,-5.038249e-37,-2.8311032e-37,-0.0018699241,-2.0313668e-21,-2.8307832e-05,-1.5497778e+25,5.4604483e+19,3.2029214e+07,1.7268085e-19,-5.981801e-25,3.539964e-29,2.3222856e-28,-1.2899205e+20,-2.509324e-32,-1.3750752e+27]':::VECTOR
AS col_2430,
0:::OID AS col_2431,
tab_1269.tableoid AS col_2432,
0:::OID AS col_2433
FROM
t131573 AS tab_1267
JOIN t131573 AS tab_1268
JOIN t131573 AS tab_1269 ON
(tab_1268.i) = (tab_1269.i)
AND (tab_1268.crdb_internal_mvcc_timestamp) = (tab_1269.crdb_internal_mvcc_timestamp) ON
(tab_1267.crdb_internal_mvcc_timestamp) = (tab_1268.crdb_internal_mvcc_timestamp)
JOIN t131573 AS tab_1270 ON
(tab_1267.crdb_internal_mvcc_timestamp) = (tab_1270.crdb_internal_mvcc_timestamp)
ORDER BY
tab_1269.crdb_internal_mvcc_timestamp,
tab_1270.crdb_internal_mvcc_timestamp,
tab_1267.crdb_internal_mvcc_timestamp,
col_2427 NULLS LAST,
tab_1268.crdb_internal_mvcc_timestamp,
tab_1269.tableoid,
tab_1267.i NULLS LAST,
col_2430,
tab_1270.tableoid
LIMIT
83:::INT8;
2 changes: 1 addition & 1 deletion pkg/sql/opt/optbuilder/orderby.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ func ensureColumnOrderable(e tree.TypedExpr) {
typ = typ.ArrayContents()
}
switch typ.Family() {
case types.TSQueryFamily, types.TSVectorFamily:
case types.TSQueryFamily, types.TSVectorFamily, types.PGVectorFamily:
panic(unimplementedWithIssueDetailf(92165, "", "can't order by column type %s", typ.SQLString()))
}
}
10 changes: 10 additions & 0 deletions pkg/sql/opt/optbuilder/testdata/orderby
Original file line number Diff line number Diff line change
Expand Up @@ -1280,3 +1280,13 @@ WHERE EXISTS(
)
----
error (0A000): subqueries in ORDER BY with non-default NULLS ordering is not supported

# TODO(#92165): Allow ordering by VECTOR columns.
exec-ddl
CREATE TABLE t_vector (v VECTOR)
----

build
SELECT * FROM t_vector ORDER BY v
----
error (0A000): unimplemented: can't order by column type VECTOR
2 changes: 1 addition & 1 deletion pkg/sql/rowcontainer/disk_row_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func MakeDiskRowContainer(
for i, orderInfo := range ordering {
d.encodings[i] = rowenc.EncodingDirToDatumEncoding(orderInfo.Direction)
switch t := typs[orderInfo.ColIdx]; t.Family() {
case types.TSQueryFamily, types.TSVectorFamily:
case types.TSQueryFamily, types.TSVectorFamily, types.PGVectorFamily:
return DiskRowContainer{}, unimplemented.NewWithIssueDetailf(
92165, "", "can't order by column type %s", t.SQLStringForError(),
)
Expand Down
Loading