File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed
main/java/com/oceanbase/odc/service/session/util
test/java/com/oceanbase/odc/service/session Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 6161import com .oceanbase .tools .sqlparser .oboracle .OBParser .Var_nameContext ;
6262import com .oceanbase .tools .sqlparser .oboracle .PLParser .IdentifierContext ;
6363import com .oceanbase .tools .sqlparser .oboracle .PLParser .Pl_schema_nameContext ;
64+ import com .oceanbase .tools .sqlparser .oboracle .PLParser .Sql_stmtContext ;
6465import com .oceanbase .tools .sqlparser .statement .Expression ;
6566import com .oceanbase .tools .sqlparser .statement .common .RelationFactor ;
6667import com .oceanbase .tools .sqlparser .statement .expression .FunctionCall ;
@@ -420,6 +421,18 @@ public RelationFactor visitPl_schema_name(Pl_schema_nameContext ctx) {
420421 return null ;
421422 }
422423
424+ @ Override
425+ public RelationFactor visitSql_stmt (Sql_stmtContext ctx ) {
426+ try {
427+ OBOracleRelationFactorVisitor visitor = new OBOracleRelationFactorVisitor ();
428+ visitor .visit (ctx );
429+ identities .addAll (visitor .getIdentities ());
430+ } catch (Exception e ) {
431+ // eat the exception
432+ }
433+ return null ;
434+ }
435+
423436 }
424437
425438
Original file line number Diff line number Diff line change 1717
1818import static org .junit .Assert .*;
1919
20+ import java .util .Collections ;
21+ import java .util .HashMap ;
2022import java .util .List ;
2123import java .util .Map ;
2224import java .util .Set ;
@@ -60,6 +62,23 @@ public void test() {
6062 }
6163 }
6264
65+ @ Test
66+ public void listDBSchemasWithSqlTypes_anonymousBlock_listSucceed () {
67+ String pl = "DECLARE\n "
68+ + " i VARCHAR2(300);\n "
69+ + "BEGIN\n "
70+ + " select ps_auto_refresh_publish_pkg.getloopup_meaning('YES_NO', 'Y') into i from dual;\n "
71+ + " dbms_output.put_line(i);\n "
72+ + "END;" ;
73+ Map <DBSchemaIdentity , Set <SqlType >> actual = DBSchemaExtractor .listDBSchemasWithSqlTypes (
74+ Collections .singletonList (SqlTuple .newTuple (pl )), DialectType .OB_ORACLE , "aps" );
75+ Map <DBSchemaIdentity , Set <SqlType >> expect = new HashMap <>();
76+ DBSchemaIdentity dbSchemaIdentity = new DBSchemaIdentity ();
77+ dbSchemaIdentity .setSchema ("PS_AUTO_REFRESH_PUBLISH_PKG" );
78+ expect .put (dbSchemaIdentity , Collections .singleton (SqlType .OTHERS ));
79+ Assert .assertEquals (expect , actual );
80+ }
81+
6382 @ Data
6483 @ NoArgsConstructor
6584 @ AllArgsConstructor
You can’t perform that action at this time.
0 commit comments