Skip to content

Commit

Permalink
Merge pull request #151 from qidi1/double_index_recommand
Browse files Browse the repository at this point in the history
repaire optimizer bug ref #150
  • Loading branch information
qidi1 authored Jan 22, 2024
2 parents 6729f37 + 6394b66 commit 11b668c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Thumbs.db
##################
.idea/
.vscode/
build
dist
venv/*
parser.out
parsetab.py
Expand Down
12 changes: 6 additions & 6 deletions db.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
'db': {
'host': 'localhost',
'port': 3306,
'dbname': 'test',
'user': 'root',
'pswd': '123456',
'charset': 'big5'
'host': '*****',
'port': '*',
'dbname': '*',
'user': '*',
'pswd': '*',
'charset': '*'
}
}
7 changes: 6 additions & 1 deletion src/metadata/metadata_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,17 @@ def json_to_catalog(catalog_json, schema_sql=None) -> Catalog:

@staticmethod
def extension_all_match_index(filter_column_list, order_list):
column_set = set()
column_list = []
range_flag = False
last_column = ''
for filter_column in filter_column_list:
column_name = filter_column['column_name']
opt = filter_column['opt']
if opt == '=' or opt == 'in' or opt == 'is':
column_list.append(column_name)
if column_name not in column_set:
column_set.add(column_name)
column_list.append(column_name)
elif (
opt == '>'
or opt == '<'
Expand All @@ -221,6 +224,8 @@ def extension_all_match_index(filter_column_list, order_list):
range_flag = True

if range_flag:
if last_column in column_set:
column_list.remove(last_column)
column_list.append(last_column)

# TODO Statistics need to be added to determine which one comes first when there are range queries and sorting
Expand Down
6 changes: 5 additions & 1 deletion src/optimizer/rewrite_rule/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
from .rewrite_or_rule import RewriteMySQLORRule
from .remove_order_by_in_delete_update_rule import RemoveOrderByInDeleteUpdateRule

common_rules = [RewriteSupplementColumnRule(), RemoveOrderByInDeleteUpdateRule()]
common_rules = [
RewriteSupplementColumnRule(),
RemoveOrderByInDeleteUpdateRule(),
RewriteMySQLORRule(),
]

mysql_rules = [RewriteMySQLORRule()]

0 comments on commit 11b668c

Please sign in to comment.