From 57b561fa6a929da206c8292778a355c9ecf51851 Mon Sep 17 00:00:00 2001 From: wlx5575 Date: Fri, 28 Jul 2023 09:45:56 +0800 Subject: [PATCH] add VtPlanValue verify --- .../com/jd/jdbc/planbuilder/PlanTest.java | 124 +++++++++++++++++- src/test/resources/plan/aggr_cases.txt | 6 +- src/test/resources/plan/dml_delete_cases.txt | 7 +- src/test/resources/plan/dml_update_cases.txt | 15 +-- src/test/resources/plan/filter_cases.txt | 62 ++++----- src/test/resources/plan/from_cases.txt | 16 +-- src/test/resources/plan/memory_sort_cases.txt | 4 +- src/test/resources/plan/one_cases.txt | 20 +++ src/test/resources/plan/postprocess_cases.txt | 30 ++--- src/test/resources/plan/select_cases.txt | 22 ++-- src/test/resources/plan/union_cases.txt | 6 +- 11 files changed, 213 insertions(+), 99 deletions(-) diff --git a/src/test/java/com/jd/jdbc/planbuilder/PlanTest.java b/src/test/java/com/jd/jdbc/planbuilder/PlanTest.java index 05972d1..698a251 100644 --- a/src/test/java/com/jd/jdbc/planbuilder/PlanTest.java +++ b/src/test/java/com/jd/jdbc/planbuilder/PlanTest.java @@ -15,13 +15,14 @@ See the License for the specific language governing permissions and limitations under the License. */ - package com.jd.jdbc.planbuilder; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Objects; import com.jd.jdbc.VSchemaManager; +import com.jd.jdbc.common.Hex; +import com.jd.jdbc.common.util.CollectionUtils; import com.jd.jdbc.engine.ConcatenateEngine; import com.jd.jdbc.engine.DeleteEngine; import com.jd.jdbc.engine.Engine; @@ -43,12 +44,17 @@ import com.jd.jdbc.evalengine.EvalEngine; import com.jd.jdbc.key.DestinationShard; import com.jd.jdbc.sqlparser.SQLUtils; +import com.jd.jdbc.sqlparser.utils.StringUtils; +import com.jd.jdbc.sqltypes.VtPlanValue; +import com.jd.jdbc.sqltypes.VtValue; import com.jd.jdbc.util.JsonUtil; import com.jd.jdbc.vindexes.VKeyspace; import io.netty.util.internal.StringUtil; +import static io.netty.util.internal.StringUtil.NEWLINE; import io.vitess.proto.Query; import java.io.BufferedReader; import java.io.IOException; +import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; @@ -58,10 +64,9 @@ import java.util.stream.Collectors; import lombok.AllArgsConstructor; import lombok.Data; -import org.junit.Test; - -import static io.netty.util.internal.StringUtil.NEWLINE; +import org.junit.Assert; import static org.junit.Assert.assertEquals; +import org.junit.Test; public class PlanTest extends AbstractPlanTest { @@ -247,6 +252,10 @@ private Instructions formatRouteEngine(RouteEngine engine) { } instructions.setSysTableKeyspaceExpr(exprList); } + List values = getValueList(engine.getVtPlanValueList()); + if (values != null) { + instructions.setValueList(values); + } return instructions; } @@ -549,6 +558,10 @@ private Instructions formatUpdateEngine(UpdateEngine engine) { instructions.setMultiShardAutocommit(engine.isMultiShardAutocommit()); instructions.setQuery(SQLUtils.toMySqlString(engine.getQuery(), SQLUtils.NOT_FORMAT_OPTION)); instructions.setTableName(engine.getTableName()); + List values = getValueList(engine.getVtPlanValueList()); + if (values != null) { + instructions.setValueList(values); + } return instructions; } @@ -566,6 +579,10 @@ private Instructions formatDeleteEngine(DeleteEngine engine) { instructions.setMultiShardAutocommit(engine.isMultiShardAutocommit()); instructions.setQuery(SQLUtils.toMySqlString(engine.getQuery(), SQLUtils.NOT_FORMAT_OPTION)); instructions.setTableName(engine.getTableName()); + List values = getValueList(engine.getVtPlanValueList()); + if (values != null) { + instructions.setValueList(values); + } return instructions; } @@ -588,6 +605,100 @@ private String formatEvalResult(EvalEngine.EvalResult evalResult) { return str; } + private List getValueList(List vtPlanValueList) { + if (CollectionUtils.isEmpty(vtPlanValueList)) { + return null; + } + List values = new ArrayList<>(); + VtPlanValue vtPlanValue1 = vtPlanValueList.get(0); + if (vtPlanValue1.getVtValue() != null && !vtPlanValue1.getVtValue().isNull() && CollectionUtils.isEmpty(vtPlanValue1.getVtPlanValueList())) { + values.add(getVtValue(vtPlanValue1.getVtValue())); + } + if (vtPlanValue1.getVtValue() != null && vtPlanValue1.getVtValue().isNull() && StringUtils.isNotEmpty(vtPlanValue1.getKey())) { + values.add(":" + vtPlanValue1.getKey()); + } + if (vtPlanValue1.getVtValue() == null && StringUtils.isNotEmpty(vtPlanValue1.getListKey())) { + values.add("::" + vtPlanValue1.getListKey()); + } + + List invalues = new ArrayList<>(); + for (VtPlanValue vtPlanValue : vtPlanValue1.getVtPlanValueList()) { + if (vtPlanValue.getVtValue() != null && !vtPlanValue.getVtValue().isNull() && CollectionUtils.isEmpty(vtPlanValue.getVtPlanValueList())) { + invalues.add(getVtValue(vtPlanValue.getVtValue())); + } + if (vtPlanValue.getVtValue() != null && vtPlanValue.getVtValue().isNull() && StringUtils.isNotEmpty(vtPlanValue.getKey())) { + invalues.add(":" + vtPlanValue.getKey()); + } + if (vtPlanValue.getVtValue() == null && StringUtils.isNotEmpty(vtPlanValue.getListKey())) { + values.add("::" + vtPlanValue.getListKey()); + } + } + if (CollectionUtils.isNotEmpty(invalues)) { + String join = String.join(", ", invalues); + values.add("(" + join + ")"); + } + return values; + } + + private String getVtValue(VtValue vtValue) { + Object object = null; + try { + switch (vtValue.getVtType()) { + case CHAR: + case VARBINARY: + case VARCHAR: + case TEXT: + case TIME: + object = "\"" + vtValue + "\""; + break; + case BIT: + object = vtValue.toBoolean(); + break; + case INT8: + case UINT8: + case INT16: + case UINT16: + case INT24: + case UINT24: + case INT32: + object = vtValue.toInt(); + break; + case UINT32: + case INT64: + object = vtValue.toLong(); + break; + case UINT64: + object = new BigInteger(vtValue.toString()); + break; + case DECIMAL: + case FLOAT32: + case FLOAT64: + object = vtValue.toDecimal(); + break; + case DATE: + case YEAR: + object = vtValue.toString(); + break; + case DATETIME: + case TIMESTAMP: + object = vtValue.toString(); + break; + case BLOB: + case BINARY: + object = Hex.encodeHexString(vtValue.getVtValue()); + break; + case NULL_TYPE: + object = null; + break; + default: + throw new RuntimeException("unknown data type:" + vtValue.getVtType()); + } + } catch (SQLException throwables) { + Assert.fail(); + } + return vtValue.getVtType().toString().toUpperCase() + "(" + object + ")"; + } + @Data @AllArgsConstructor private static class TestCase { @@ -727,6 +838,7 @@ public boolean equals(Object o) { Objects.equal(fieldQuery, that.fieldQuery) && Objects.equal(query, that.query) && Objects.equal(table, that.table) && + Objects.equal(valueList, that.valueList) && Objects.equal(joinColumnIndexes, that.joinColumnIndexes) && Objects.equal(tableName, that.tableName) && Objects.equal(columns, that.columns) && @@ -742,8 +854,8 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(operatorType, variant, aggregates, distinct, groupBy, orderBy, count, keyspace, targetTabletType, multiShardAutocommit, fieldQuery, query, table, joinColumnIndexes, - tableName, columns, strColumns, sysTableKeyspaceExpr, expressions, inputs, targetDestination, isDML, singleShardOnly, shardNameNeeded); + return Objects.hashCode(operatorType, variant, aggregates, distinct, groupBy, orderBy, count, keyspace, targetTabletType, multiShardAutocommit, fieldQuery, query, table, valueList, + joinColumnIndexes, tableName, columns, strColumns, sysTableKeyspaceExpr, expressions, inputs, targetDestination, isDML, singleShardOnly, shardNameNeeded); } @Override diff --git a/src/test/resources/plan/aggr_cases.txt b/src/test/resources/plan/aggr_cases.txt index 08abb72..5360cd7 100644 --- a/src/test/resources/plan/aggr_cases.txt +++ b/src/test/resources/plan/aggr_cases.txt @@ -34,7 +34,7 @@ "Query": "select count(*), col from user where name = 1", "Table": "user", "Values": [ - 1 + "INT64(1)" ], "Vindex": "user_index" } @@ -463,7 +463,7 @@ "Query": "select name, count(*) as c from user group by name having name = 1 and c = 10", "Table": "user", "Values": [ - 1 + "INT64(1)" ], "Vindex": "user_index" } @@ -1066,7 +1066,7 @@ "Query": "select user.col1 as a from user where user.name = 5 group by a collate utf8_general_ci", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } diff --git a/src/test/resources/plan/dml_delete_cases.txt b/src/test/resources/plan/dml_delete_cases.txt index 3d267b7..e6e88ce 100644 --- a/src/test/resources/plan/dml_delete_cases.txt +++ b/src/test/resources/plan/dml_delete_cases.txt @@ -91,7 +91,7 @@ "Query": "delete from music_extra where user_id = 1", "TableName": "music_extra", "Values": [ - 1 + "INT64(1)" ], "Vindex": "user_index" } @@ -171,10 +171,7 @@ "Query": "delete from user_extra where user_id in (1, 2)", "TableName": "user_extra", "Values": [ - [ - 1, - 2 - ] + "(INT64(1), INT64(2))" ], "Vindex": "user_index" } diff --git a/src/test/resources/plan/dml_update_cases.txt b/src/test/resources/plan/dml_update_cases.txt index 7ead33c..757d416 100644 --- a/src/test/resources/plan/dml_update_cases.txt +++ b/src/test/resources/plan/dml_update_cases.txt @@ -37,7 +37,7 @@ "Query": "update user set val = 1 where name = 'foo'", "TableName": "user", "Values": [ - 1 + "VARCHAR(\"foo\")" ], "Vindex": "user_index" } @@ -60,7 +60,7 @@ "Query": "update user as user_alias set val = 1 where user_alias.name = 'foo'", "TableName": "user", "Values": [ - 1 + "VARCHAR(\"foo\")" ], "Vindex": "user_index" } @@ -83,7 +83,7 @@ "Query": "update user set val = 1 where name = 'foo'", "TableName": "user", "Values": [ - 1 + "VARCHAR(\"foo\")" ], "Vindex": "user_index" } @@ -178,7 +178,7 @@ "Query": "update user set val = 1 where name = 'foo' and id = 1", "TableName": "user", "Values": [ - 1 + "VARCHAR(\"foo\")" ], "Vindex": "user_index" } @@ -201,7 +201,7 @@ "Query": "update user set val = 1 where name = 'foo' and name = '1'", "TableName": "user", "Values": [ - 1 + "VARCHAR(\"foo\")" ], "Vindex": "user_index" } @@ -299,10 +299,7 @@ "Query": "update user_extra set val = 1 where user_id in (1, 2)", "TableName": "user_extra", "Values": [ - [ - 1, - 2 - ] + "(INT64(1), INT64(2))" ], "Vindex": "user_index" } diff --git a/src/test/resources/plan/filter_cases.txt b/src/test/resources/plan/filter_cases.txt index 65b33bb..0ffae1f 100644 --- a/src/test/resources/plan/filter_cases.txt +++ b/src/test/resources/plan/filter_cases.txt @@ -51,7 +51,7 @@ "Query": "select name from user where user.name = 5", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -91,7 +91,7 @@ "Query": "select id from music where id = 5 and user_id = 4", "Table": "music", "Values": [ - 4 + "INT64(4)" ], "Vindex": "user_index" } @@ -131,8 +131,7 @@ "Query": "select name from user where user.col = 5 and user.name in (::__vals)", "Table": "user", "Values": [ - 1, - 2 + "(INT64(1), INT64(2))" ], "Vindex": "user_index" } @@ -154,8 +153,7 @@ "Query": "select name from user where user.col = case user.col when 'foo' then true else false end and user.name in (::__vals)", "Table": "user", "Values": [ - 1, - 2 + "(INT64(1), INT64(2))" ], "Vindex": "user_index" } @@ -177,7 +175,7 @@ "Query": "select id from user where user.col = 5 and user.id in (1, 2) and user.name = 'aa' and user.id = 1", "Table": "user", "Values": [ - 1 + "VARCHAR(\"aa\")" ], "Vindex": "user_index" } @@ -199,7 +197,7 @@ "Query": "select id from user where user.id = 1 and user.name = 'aa' and user.id in (1, 2) and user.col = 5", "Table": "user", "Values": [ - 1 + "VARCHAR(\"aa\")" ], "Vindex": "user_index" } @@ -239,7 +237,6 @@ "Query": "select user_id from music where user_id is null", "Table": "music", "Values": [ - null ], "Vindex": "music_user_map" } @@ -315,7 +312,7 @@ "Query": "select id from music where user_id = 4 and id in (null, 1, 2)", "Table": "music", "Values": [ - 4 + "INT64(4)" ], "Vindex": "user_index" } @@ -355,7 +352,7 @@ "Query": "select user_extra.id from user join user_extra on user.name = user_extra.user_id where user.name = 5", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -377,7 +374,7 @@ "Query": "select user_extra.id from user join user_extra on user.name = user_extra.user_id where user_extra.user_id = 5", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -399,7 +396,7 @@ "Query": "select user_extra.id from user left join user_extra on user.name = user_extra.user_id where user.name = 5", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -421,7 +418,7 @@ "Query": "select user_extra.id from user left join user_extra on user.name = user_extra.user_id where user_extra.user_id = 5", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -449,7 +446,7 @@ "Query": "select user.col from user where user.name = 5", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" }, @@ -490,7 +487,7 @@ "Query": "select user.col from user where user.name = 5", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" }, @@ -505,7 +502,7 @@ "Query": "select user_extra.id from user_extra where user_extra.col = :user_col and user_extra.user_id = 5", "Table": "user_extra", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -607,7 +604,7 @@ "Query": "select user_extra.Id from user join user_extra on user.nAME = user_extra.User_Id where user.Name = 5", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -646,7 +643,7 @@ "Query": "select id from user where name = 18446744073709551615", "Table": "user", "Values": [ - 18446744073709551615 + "UINT64(18446744073709551615)" ], "Vindex": "name_user_map" } @@ -668,7 +665,7 @@ "Query": "select id from user where costly = 'aa' and name = 'bb'", "Table": "user", "Values": [ - "bb" + "VARCHAR(\"bb\")" ], "Vindex": "name_user_map" } @@ -690,10 +687,7 @@ "Query": "select id from user where costly in ('aa', 'bb') and name in (::__vals)", "Table": "user", "Values": [ - [ - "aa", - "bb" - ] + "(VARCHAR(\"aa\"), VARCHAR(\"bb\"))" ], "Vindex": "name_user_map" } @@ -715,7 +709,7 @@ "Query": "select id or col as val from user where user.col = 5 and user.id in (1, 2) and user.name = 'aa'", "Table": "user", "Values": [ - "aa" + "VARCHAR(\"aa\")" ], "Vindex": "name_user_map" } @@ -759,7 +753,7 @@ "Query": "select id from user where user.col = false and user.id in (1, 2) and user.name = 'aa'", "Table": "user", "Values": [ - "aa" + "VARCHAR(\"aa\")" ], "Vindex": "name_user_map" } @@ -798,10 +792,7 @@ "Query": "select u.m from user as u where u.name in (::__vals) and u.name in ( select m2 from user where user.name = u.name and user.col = :user_extra_col )", "Table": "user", "Values": [ - [ - ":user_extra_col", - 1 - ] + "(:user_extra_col, INT64(1))" ], "Vindex": "hash" } @@ -842,7 +833,7 @@ "Query": "select u.m from user as u where u.name = 5 and u.name in ( select m2 from user where user.name = 5 )", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "hash" } @@ -883,10 +874,7 @@ "Query": "select u.m from user as u where u.name in (::__vals) and u.name in ( select m2 from user where user.name = u.name and user.col = :user_extra_col and user.name in ( select m3 from user_extra where user_extra.user_id = user.name ) )", "Table": "user", "Values": [ - [ - ":user_extra_col", - 1 - ] + "(:user_extra_col, INT64(1))" ], "Vindex": "user_index" } @@ -928,7 +916,7 @@ "Query": "select id from user where name = 5 and user.col in ( select user_extra.col from user_extra where user_extra.user_id = 5 )", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -950,7 +938,7 @@ "Query": "select id from user where name = 'aa' and user.col in ( select user_extra.col from user_extra where user_extra.user_id = 'aa' )", "Table": "user", "Values": [ - "aa" + "VARCHAR(\"aa\")" ], "Vindex": "user_index" } diff --git a/src/test/resources/plan/from_cases.txt b/src/test/resources/plan/from_cases.txt index e6e8037..eb7b3f0 100644 --- a/src/test/resources/plan/from_cases.txt +++ b/src/test/resources/plan/from_cases.txt @@ -426,7 +426,7 @@ "Query": "select user.col from user join user_extra on user.name = 5 and user.name = user_extra.user_id", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -491,7 +491,7 @@ "Query": "select user.col from user where user.name = 5", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "hash" }, @@ -532,7 +532,7 @@ "Query": "select user.col from user where user.name = 5", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "hash" }, @@ -659,7 +659,7 @@ "Query": "select id from ( select id, col from user where name = 5 ) t", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "hash" } @@ -681,7 +681,7 @@ "Query": "select t.name from ( select name from user where name = 5 ) t join user_extra on t.name = user_extra.user_id", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "hash" } @@ -703,7 +703,7 @@ "Query": "select t.name from ( select user.name from user where user.name = 5 ) t join user_extra on t.name = user_extra.user_id", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -753,7 +753,7 @@ "Query": "select t.name from ( select name from user where name = 5 ) t", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" }, @@ -788,7 +788,7 @@ "Query": "select u.col, e.col from ( select col from user where name = 5 ) u join ( select col from user_extra where user_id = 5 ) e", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "hash" } diff --git a/src/test/resources/plan/memory_sort_cases.txt b/src/test/resources/plan/memory_sort_cases.txt index a5c56e3..1a6f8b8 100644 --- a/src/test/resources/plan/memory_sort_cases.txt +++ b/src/test/resources/plan/memory_sort_cases.txt @@ -236,7 +236,7 @@ "Query": "select user.col1 as a, user.col2 as b, user.name from user where user.name = 1", "Table": "user", "Values": [ - 1 + "INT64(1)" ], "Vindex": "hash" }, @@ -288,7 +288,7 @@ "Query": "select user.col1 as a, user.col2, user.name from user where user.name = 1", "Table": "user", "Values": [ - 1 + "INT64(1)" ], "Vindex": "hash" }, diff --git a/src/test/resources/plan/one_cases.txt b/src/test/resources/plan/one_cases.txt index e69de29..6473001 100644 --- a/src/test/resources/plan/one_cases.txt +++ b/src/test/resources/plan/one_cases.txt @@ -0,0 +1,20 @@ +"select *, id, name from pin_test" +{ + "QueryType": "SELECT", + "Original": "select *, id, name from pin_test", + "Instructions": { + "OperatorType": "Route", + "Variant": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "FieldQuery": "select *, id, name from pin_test where 1 != 1", + "Query": "select *, id, name from pin_test", + "Table": "pin_test", + "Values": [ + "VARBINARY(\"\b\u0000\")" + ], + "Vindex": "binary" + } +} \ No newline at end of file diff --git a/src/test/resources/plan/postprocess_cases.txt b/src/test/resources/plan/postprocess_cases.txt index eb8f342..71204d6 100644 --- a/src/test/resources/plan/postprocess_cases.txt +++ b/src/test/resources/plan/postprocess_cases.txt @@ -32,7 +32,7 @@ "Query": "select col from user where name = 5 order by aa asc", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -54,7 +54,7 @@ "Query": "select col from user where name = 1 order by 1 asc", "Table": "user", "Values": [ - 1 + "INT64(1)" ], "Vindex": "user_index" } @@ -224,7 +224,7 @@ "Query": "select * from user where name = 5 order by col asc", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -246,7 +246,7 @@ "Query": "select user.* from user where name = 5 order by user.col asc", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -268,7 +268,7 @@ "Query": "select * from user where name = 5 order by user.col asc", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -302,7 +302,7 @@ "Query": "select * from user where name = 5 order by user.col collate utf8_general_ci asc", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -324,7 +324,7 @@ "Query": "select * from user where name = 5 order by -col1 asc", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -346,7 +346,7 @@ "Query": "select * from user where name = 5 order by concat(col, col1) collate utf8_general_ci desc", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -368,7 +368,7 @@ "Query": "select * from user where name = 5 order by name + col collate utf8_general_ci desc", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -390,7 +390,7 @@ "Query": "select col1 from user where name = 1 limit 1", "Table": "user", "Values": [ - 1 + "INT64(1)" ], "Vindex": "user_index" } @@ -544,7 +544,7 @@ "Query": "select user.col1 as a, user.col2, user.name from user where user.name = 1 order by null", "Table": "user", "Values": [ - 1 + "INT64(1)" ], "Vindex": "hash" }, @@ -585,7 +585,7 @@ "Query": "select user.col1 as a, user.col2, user.name from user where user.name = 1 order by a asc", "Table": "user", "Values": [ - 1 + "INT64(1)" ], "Vindex": "hash" }, @@ -626,7 +626,7 @@ "Query": "select user.col1 as a, user.col2, user.name from user where user.name = 1 order by a asc", "Table": "user", "Values": [ - 1 + "INT64(1)" ], "Vindex": "hash" }, @@ -667,7 +667,7 @@ "Query": "select user.col1 as a, user.col2, user.name from user where user.name = 1 order by RAND()", "Table": "user", "Values": [ - 1 + "INT64(1)" ], "Vindex": "hash" }, @@ -935,7 +935,7 @@ "Query": "select * from user as u join ( select user_id from user_extra where user_id = 5 ) eu on u.name = eu.user_id where u.name = 5 order by eu.user_id asc", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } diff --git a/src/test/resources/plan/select_cases.txt b/src/test/resources/plan/select_cases.txt index d71a70d..ee4f7c4 100644 --- a/src/test/resources/plan/select_cases.txt +++ b/src/test/resources/plan/select_cases.txt @@ -128,7 +128,7 @@ } } -# select from pinned table +# select from pinned table // 怀疑是gen3 Values这里保存的有问题,但是pin表也不会用到这个值,先以gen3为准 "select *, id, name from pin_test" { "QueryType": "SELECT", @@ -144,7 +144,7 @@ "Query": "select *, id, name from pin_test", "Table": "pin_test", "Values": [ - "\ufffd" + "VARBINARY(\"\b\u0000\")" ], "Vindex": "binary" } @@ -209,7 +209,7 @@ "Query": "select * from user where name = 'abc' and id = 4 limit 5", "Table": "user", "Values": [ - 4 + "VARCHAR(\"abc\")" ], "Vindex": "user_index" } @@ -231,7 +231,7 @@ "Query": "select * from user where id = 4 and name = 'abc' limit 5", "Table": "user", "Values": [ - 4 + "VARCHAR(\"abc\")" ], "Vindex": "user_index" } @@ -253,7 +253,7 @@ "Query": "select user0_.col as col0_ from user as user0_ where name = 1 order by user0_.col desc limit 2", "Table": "user", "Values": [ - 1 + "INT64(1)" ], "Vindex": "user_index" } @@ -275,7 +275,7 @@ "Query": "select user0_.col as col0_ from user as user0_ where name = 1 order by col0_ desc limit 3", "Table": "user", "Values": [ - 1 + "INT64(1)" ], "Vindex": "user_index" } @@ -297,7 +297,7 @@ "Query": "select * from user where name = 1 and name = true limit 5", "Table": "user", "Values": [ - 1 + "INT64(1)" ], "Vindex": "user_index" } @@ -319,7 +319,7 @@ "Query": "select * from user where name = 1 and name limit 5", "Table": "user", "Values": [ - 1 + "INT64(1)" ], "Vindex": "user_index" } @@ -341,7 +341,7 @@ "Query": "select * from user where name = 5 and name = true limit 5", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -363,7 +363,7 @@ "Query": "select * from music where user_id = 1", "Table": "music", "Values": [ - 1 + "INT64(1)" ], "Vindex": "user_index" } @@ -855,7 +855,7 @@ "Query": "select * from music where user_id = 1 union select * from user where name = 1", "Table": "music", "Values": [ - 1 + "INT64(1)" ], "Vindex": "user_index" } diff --git a/src/test/resources/plan/union_cases.txt b/src/test/resources/plan/union_cases.txt index d6cd970..74b5bcb 100644 --- a/src/test/resources/plan/union_cases.txt +++ b/src/test/resources/plan/union_cases.txt @@ -51,7 +51,7 @@ "Query": "select id from user where name = 1", "Table": "user", "Values": [ - 1 + "INT64(1)" ], "Vindex": "user_index" }, @@ -66,7 +66,7 @@ "Query": "select id from user where name = 5", "Table": "user", "Values": [ - 5 + "INT64(5)" ], "Vindex": "user_index" } @@ -261,7 +261,7 @@ "Query": "select id from user where name = 1 union select id from user where name = 1", "Table": "user", "Values": [ - 1 + "INT64(1)" ], "Vindex": "user_index" },