Skip to content
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
3 changes: 2 additions & 1 deletion pyobvector/schema/reflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def _prep_regexes(self):
r"(?: +USING +(?P<using_post>\S+))?"
r"(?: +WITH +\((?P<vector_params>[^)]+)\))?"
r"(?: +WITH PARSER +(?P<parser>\S+))?"
r"(?: +PARSER_PROPERTIES=\((?P<parser_properties>[^)]+)\))?"
r"(?: +PARSER_PROPERTIES *[ =]? *\((?P<parser_properties>[^)]+)\))?"
r"(?: +FTS_INDEX_TYPE *[ =]? *(?P<fts_index_type>\S+))?"
Comment thread
whhe marked this conversation as resolved.
r"(?: +(KEY_)?BLOCK_SIZE *[ =]? *(?P<keyblock>\S+) *(LOCAL)?)?"
r"(?: +COMMENT +(?P<comment>(\x27\x27|\x27([^\x27])*?\x27)+))?"
r"(?: +/\*(?P<version_sql>.+)\*/ *)?"
Expand Down
25 changes: 25 additions & 0 deletions tests/test_reflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,28 @@ def test_customized_fulltext_parser(self):
state = dialect._tabledef_parser.parse(ddl, "utf8")
assert len(state.columns) == 4
assert len(state.keys) == 3

def test_analyzer_fulltext_parser_properties_and_fts_index_type(self):
dialect = OceanBaseDialect()
parser_properties = 'analysis = \'{"analyzer": "standard"}\''
fulltext_key = (
" FULLTEXT KEY `fts_idx_question_tks` (`question_tks`)"
" WITH PARSER analyzer"
f" PARSER_PROPERTIES = ({parser_properties})"
" FTS_INDEX_TYPE = PHRASE_MATCH BLOCK_SIZE 16384"
)
ddl = (
"CREATE TABLE `t_fts_analyzer` (\n"
" `id` bigint NOT NULL,\n"
" `question_tks` longtext DEFAULT NULL,\n"
" PRIMARY KEY (`id`),\n"
f"{fulltext_key}\n"
") DEFAULT CHARSET = utf8mb4\n"
)
state = dialect._tabledef_parser.parse(ddl, "utf8")
assert len(state.columns) == 2
assert len(state.keys) == 2
fts_key = next(k for k in state.keys if k.get("parser") == "analyzer")
assert fts_key["name"] == "fts_idx_question_tks"
assert "standard" in fts_key["parser_properties"]
assert fts_key["fts_index_type"] == "PHRASE_MATCH"
Loading