Class TMetadataCollector

Object
gudusoft.gsqlparser.nodes.TParseTreeVisitor
gudusoft.gsqlparser.resolver.TMetadataCollector

TMetadataCollector is responsible for collecting metadata information from SQL statements, particularly focusing on table and function definitions. It traverses the parse tree and builds up metadata in the global scope.
  • Constructor Details

    • TMetadataCollector

      public TMetadataCollector(TStatementList sqls, gudusoft.gsqlparser.compiler.TContext context)
      Constructor for TMetadataCollector. Initializes the collector with a list of SQL statements and a global context.
      Parameters:
      sqls - List of SQL statements to analyze
      context - Global context that will store collected metadata
  • Method Details

    • collect

      public void collect()
      Main method to start metadata collection process. Iterates through all SQL statements and collects metadata from each one. This includes: - Table definitions from CREATE TABLE statements - Function definitions from CREATE FUNCTION statements - Other metadata from various SQL statements
    • preVisit

      public void preVisit(TCreateTableSqlStatement stmt)
      Processes CREATE TABLE statements to collect table metadata. Handles both regular table creation and CREATE TABLE AS SELECT.
      Overrides:
      preVisit in class TParseTreeVisitor
      Parameters:
      stmt - The CREATE TABLE statement to process Actions performed: 1. Creates new table entry in SQL environment 2. Sets table name and resolves it 3. Processes column definitions 4. Handles subquery-based table creation
    • preVisit

      public void preVisit(TCreateFunctionStmt stmt)
      Processes CREATE FUNCTION statements to collect function metadata. Captures function name, parameters, and return type information.
      Overrides:
      preVisit in class TParseTreeVisitor
      Parameters:
      stmt - The CREATE FUNCTION statement to process Actions performed: 1. Creates new function entry in SQL environment 2. Processes function parameters 3. Sets function return type