Class ChParserUtils
java.lang.Object
org.pgcodekeeper.core.database.ch.parser.ChParserUtils
Utility methods for ClickHouse SQL parsing with ANTLR.
Provides helper functions for working with ClickHouse SQL syntax during ANTLR-based parsing
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckToCleanChParser(long cleaningInterval) Checks if parser caches need cleaning based on last usage time.static voidClears the ClickHouse parser cache.static CHParsercreateParser(InputStream is, String charset, String parsedObjectName, List<Object> errors) Creates a ClickHouse SQL parser from input stream.static CHParsercreateParser(String sql, String parsedObjectName, List<Object> errors) Creates a ClickHouse SQL parser from string input.static StringgetTokenText(int type, org.antlr.v4.runtime.Token token) static booleanisSpecialChar(int type, int previous) static StringnormalizeWhitespaceUnquoted(org.antlr.v4.runtime.ParserRuleContext ctx, org.antlr.v4.runtime.CommonTokenStream stream) static QNameParser<org.antlr.v4.runtime.ParserRuleContext>parseQName(String schemaQualifiedName) Parses a ClickHouse qualified name into its components.static voidparseSqlStream(InputStreamProvider inputStream, String parsedObjectName, DiffSettings diffSettings, int monitoringLevel, IChContextProcessor listener, Queue<AntlrTask<?>> antlrTasks) Parses ClickHouse SQL stream asynchronously.static QNameParserWrapperwrapParsedQName(String fullName) Creates a wrapper for parsing ClickHouse qualified names.
-
Method Details
-
createParser
Creates a ClickHouse SQL parser from string input.- Parameters:
sql- ClickHouse SQL string to parseparsedObjectName- name of the object being parsed (for error reporting)errors- list to collect parsing errors- Returns:
- configured CHParser instance
-
createParser
public static CHParser createParser(InputStream is, String charset, String parsedObjectName, List<Object> errors) throws IOException Creates a ClickHouse SQL parser from input stream.- Parameters:
is- input stream containing ClickHouse SQLcharset- character encoding of the streamparsedObjectName- name of the object being parsederrors- list to collect parsing errors- Returns:
- configured CHParser instance
- Throws:
IOException- if there's an error reading the stream
-
parseSqlStream
public static void parseSqlStream(InputStreamProvider inputStream, String parsedObjectName, DiffSettings diffSettings, int monitoringLevel, IChContextProcessor listener, Queue<AntlrTask<?>> antlrTasks) Parses ClickHouse SQL stream asynchronously.- Parameters:
inputStream- provider of the input streamparsedObjectName- name of the object being parseddiffSettings- unified context object containing settings, monitor, and error accumulatormonitoringLevel- level of parse tree monitoringlistener- processor for the parsed contentantlrTasks- queue for parser tasks
-
checkToCleanChParser
public static void checkToCleanChParser(long cleaningInterval) Checks if parser caches need cleaning based on last usage time.- Parameters:
cleaningInterval- time interval in milliseconds after which cache should be cleaned
-
cleanCacheChParser
public static void cleanCacheChParser()Clears the ClickHouse parser cache. -
isSpecialChar
public static boolean isSpecialChar(int type, int previous) -
normalizeWhitespaceUnquoted
public static String normalizeWhitespaceUnquoted(org.antlr.v4.runtime.ParserRuleContext ctx, org.antlr.v4.runtime.CommonTokenStream stream) -
getTokenText
-
parseQName
public static QNameParser<org.antlr.v4.runtime.ParserRuleContext> parseQName(String schemaQualifiedName) Parses a ClickHouse qualified name into its components.- Parameters:
schemaQualifiedName- the qualified name string to parse- Returns:
- QNameParser instance containing parsed components
-
wrapParsedQName
Creates a wrapper for parsing ClickHouse qualified names.- Parameters:
fullName- the qualified name string to parse- Returns:
- wrapper containing parsed name components
-