File tree 3 files changed +29
-2
lines changed
3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ static void LoadInternal(DatabaseInstance &db) {
110
110
111
111
config.AddExtensionOption (" mysql_experimental_filter_pushdown" ,
112
112
" Whether or not to use filter pushdown (currently experimental)" , LogicalType::BOOLEAN,
113
- Value::BOOLEAN (false ));
113
+ Value::BOOLEAN (true ));
114
114
config.AddExtensionOption (" mysql_debug_show_queries" , " DEBUG SETTING: print all queries sent to MySQL to stdout" ,
115
115
LogicalType::BOOLEAN, Value::BOOLEAN (false ), SetMySQLDebugQueryPrint);
116
116
config.AddExtensionOption (" mysql_tinyint1_as_boolean" , " Whether or not to convert TINYINT(1) columns to BOOLEAN" ,
Original file line number Diff line number Diff line change @@ -30,12 +30,26 @@ string MySQLFilterPushdown::TransformComparison(ExpressionType type) {
30
30
}
31
31
}
32
32
33
+
34
+ static string TransformBlobToMySQL (const string &val) {
35
+ char const HEX_DIGITS[] = " 0123456789ABCDEF" ;
36
+
37
+ string result = " x'" ;
38
+ for (idx_t i = 0 ; i < val.size (); i++) {
39
+ uint8_t byte_val = static_cast <uint8_t >(val[i]);
40
+ result += HEX_DIGITS[(byte_val >> 4 ) & 0xf ];
41
+ result += HEX_DIGITS[byte_val & 0xf ];
42
+ }
43
+ result += " '" ;
44
+ return result;
45
+ }
46
+
33
47
string MySQLFilterPushdown::TransformConstant (const Value &val) {
34
48
if (val.type ().IsNumeric ()) {
35
49
return val.ToSQLString ();
36
50
}
37
51
if (val.type ().id () == LogicalTypeId::BLOB) {
38
- throw NotImplementedException ( " Unsupported type for filter pushdown: BLOB " );
52
+ return TransformBlobToMySQL ( StringValue::Get (val) );
39
53
}
40
54
if (val.type ().id () == LogicalTypeId::TIMESTAMP_TZ) {
41
55
return val.DefaultCastAs (LogicalType::TIMESTAMP).DefaultCastAs (LogicalType::VARCHAR).ToSQLString ();
Original file line number Diff line number Diff line change @@ -66,3 +66,16 @@ SELECT COLUMNS(*)::VARCHAR FROM s.all_types
66
66
false -128 -32768 -2147483648 -9223372036854775808 0 0 0 2000-01-01 00:00:00 2000-01-01 01:02:03 2000-01-01 01:02:03 2000-01-01 01:02:03 2000-01-01 01:02:03 00:00:00+15:00 2000-01-01 01:02:03 -999.9 -99999.9999 -999999999999.999999 -9999999999999999999999999999.9999999999 00000000-0000-0000-0000-000000000000 00:00:00 🦆🦆🦆🦆🦆🦆 thisisalongblob\x00withnullbytes 0010001001011100010101011010111 DUCK_DUCK_ENUM enum_0 enum_0
67
67
true 127 32767 2147483647 9223372036854775807 255 65535 4294967295 2000-01-01 24:00:00 2000-01-01 01:02:03 2000-01-01 01:02:03 2000-01-01 01:02:03 2000-01-01 01:02:03 00:00:00+15:00 2000-01-01 01:02:03 999.9 99999.9999 999999999999.999999 9999999999999999999999999999.9999999999 ffffffff-ffff-ffff-ffff-ffffffffffff 83 years 3 months 999 days 00:16:39.999999 goo\0se \x00\x00\x00a 10101 GOOSE enum_299 enum_69999
68
68
NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
69
+
70
+ # filter pushdown
71
+ foreach column_name bool tinyint smallint int bigint utinyint usmallint uint date time timestamp timestamp_s timestamp_ms timestamp_ns time_tz timestamp_tz dec_4_1 dec_9_4 dec_18_6 dec38_10 uuid interval varchar blob bit small_enum medium_enum large_enum
72
+
73
+ statement ok
74
+ SET VARIABLE minimum_value=(SELECT MIN(${column_name}) min_val FROM s.all_types);
75
+
76
+ query I
77
+ SELECT ANY_VALUE(${column_name})=getvariable('minimum_value') FROM s.all_types WHERE ${column_name}=getvariable('minimum_value')
78
+ ----
79
+ true
80
+
81
+ endloop
You can’t perform that action at this time.
0 commit comments