Implement OR REPLACE clause support for CREATE FUNCTION statements #171
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #23 by implementing complete support for the
OR REPLACE
clause in CREATE FUNCTION statements, bringing it in line with existing TABLE and VIEW support.Changes Made
1. Extended CreateFunction AST Node
OrReplace bool
field toCreateFunction
struct inparser/ast.go
CreateFunction.String()
method to properly format "CREATE OR REPLACE FUNCTION" syntax2. Updated Parser Logic
parseCreateFunction()
to acceptorReplace
parameterorReplace
flag to function parsing3. Enhanced Test Coverage
create_or_replace.sql
test with CREATE OR REPLACE FUNCTION exampleSyntax Support
The parser now supports all three ClickHouse OR REPLACE syntaxes:
Validation
The implementation includes proper error handling:
Backward Compatibility
All existing functionality is preserved:
OrReplace: false
for existing statementsTesting
The implementation includes comprehensive test coverage:
This completes the ClickHouse SQL parser's support for OR REPLACE clauses across all major object types as documented in the ClickHouse specifications.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.