From ec67e69e2572d2b4924f41d2a57847ae526d1f49 Mon Sep 17 00:00:00 2001 From: andrew Date: Wed, 10 Jan 2024 16:00:11 +0300 Subject: [PATCH] fix describe model.version.attribute #326 --- mindsdb_sql/parser/dialects/mindsdb/lexer.py | 2 +- .../test_base_sql/test_describe.py | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/mindsdb_sql/parser/dialects/mindsdb/lexer.py b/mindsdb_sql/parser/dialects/mindsdb/lexer.py index 752dddaf..73a61aac 100644 --- a/mindsdb_sql/parser/dialects/mindsdb/lexer.py +++ b/mindsdb_sql/parser/dialects/mindsdb/lexer.py @@ -295,7 +295,7 @@ class MindsDBLexer(Lexer): def ID(self, t): return t - @_(r'\d+\.\d*') + @_(r'\d+\.\d+') def FLOAT(self, t): return t diff --git a/tests/test_parser/test_base_sql/test_describe.py b/tests/test_parser/test_base_sql/test_describe.py index 60c1d908..4032f754 100644 --- a/tests/test_parser/test_base_sql/test_describe.py +++ b/tests/test_parser/test_base_sql/test_describe.py @@ -31,3 +31,28 @@ def test_describe_predictor(self): assert str(ast) == str(expected_ast) assert ast.to_tree() == expected_ast.to_tree() + # describe attr + sql = "DESCRIBE MODEL pred.attr" + ast = parse_sql(sql, dialect='mindsdb') + + expected_ast = Describe(type='predictor', value=Identifier(parts=['pred', 'attr'])) + + assert str(ast) == str(expected_ast) + + # version + sql = "DESCRIBE MODEL pred.11" + ast = parse_sql(sql, dialect='mindsdb') + + expected_ast = Describe(type='predictor', value=Identifier(parts=['pred', '11'])) + + assert str(ast) == str(expected_ast) + + # version and attr + sql = "DESCRIBE MODEL pred.11.attr" + ast = parse_sql(sql, dialect='mindsdb') + + expected_ast = Describe(type='predictor', value=Identifier(parts=['pred', '11', 'attr'])) + + assert str(ast) == str(expected_ast) + +