shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

Help with correct Create View support

Open makssent opened this issue 2 years ago • 7 comments

Hello everyone,

I recently encountered a problem that I've been struggling with for a long time. I implemented a CREATE VIEW statement for my database, and it looks like this:

createView
    : (CREATE (OR ALTER)? VIEW)
      viewName viewAliasClause? 
      AS select 
      (WITH (CASCADED | LOCAL)? CHECK OPTION)?
    ;
    
    viewAliasClause
    : LP_ viewAlias (COMMA_ viewAlias)* RP_
    ;

    viewAlias
    : columnName (AS alias)?
    ;
    
    viewName
    : (owner DOT_)? identifier
    ;

    columnName
    : (owner DOT_)? name
    ;
    
    name
    : identifier
    ;
 
   owner
    : identifier
    ;

    @Override
    public ASTNode visitCreateView(final CreateViewContext ctx) {
        FirebirdCreateViewStatement result = new FirebirdCreateViewStatement();
        result.setView((SimpleTableSegment) visit(ctx.viewName()));
        result.setViewDefinition(getOriginalText(ctx.select()));
        result.setSelect((SelectStatement) visit(ctx.select()));
        return result;
    }

error:

class org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment cannot be cast to class
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement
(org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment and
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement are in unnamed module of loader 'app')

Log Trace:

org.apache.shardingsphere.sql.parser.firebird.visitor.statement.type.FirebirdDDLStatementVisitor.visitCreateView(FirebirdDDLStatementVisitor.java:329) 
org.apache.shardingsphere.sql.parser.firebird.visitor.statement.type.FirebirdDDLStatementVisitor.visitCreateView(FirebirdDDLStatementVisitor.java:92) 
org.apache.shardingsphere.sql.parser.autogen.FirebirdStatementParser$CreateViewContext.accept(FirebirdStatementParser.java:3466) 
org.apache.shardingsphere.sql.parser.api.SQLStatementVisitorEngine.visit(SQLStatementVisitorEngine.java:52) 
org.apache.shardingsphere.infra.parser.sql.SQLStatementParserExecutor.parse(SQLStatementParserExecutor.java:47) 
org.apache.shardingsphere.infra.parser.sql.SQLStatementParserEngine.parse(SQLStatementParserEngine.java:57) 
org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine.parse(ShardingSphereSQLParserEngine.java:53) 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.createQueryContext(ShardingSphereStatement.java:533)
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.execute0(ShardingSphereStatement.java:461) 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.execute(ShardingSphereStatement.java:408) 
Tester.testcheck(Tester.java:43) Connections.dbconnection(Connections.java:409) Main.main(Main.java:35)

This issue also occurs with MERGE, where the 'AS select' construct is used, and the same error appears there. If we use the 'begin statement' structure as we do in CREATE FUNCTION and CREATE PROCEDURE, everything works fine, even when using CREATE VIEW or MERGE.

Does anyone have any ideas on how I can resolve this issue or where I can look for a solution?

I'm sorry if I wrote in the wrong section or with the wrong tag


project-link: https://github.com/makssent/shardingsphere/tree/CreateViewStatement

Documentation: https://www.firebirdsql.net/file/documentation/chunk/en/refdocs/fblangref50/fblangref50-ddl-view.html

makssent avatar Oct 02 '24 14:10 makssent

What is your purpose? Are you meeting issues while using ShardingSphere, or are you attempting to develop code on your own? If you're developing code, is it for ShardingSphere, or are you using ANTLR to create new code? Could you please provide some context?

terrymanu avatar Oct 02 '24 15:10 terrymanu

I am part of a team that is developing Firebird support based on ShardingSphere. We are working on full Firebird support, including the dialect, tests, driver support, etc. I have encountered a problem that I cannot solve on my own, so I decided to seek help from the community and share that we are working on supporting ShardingSphere for Firebird.

I have already spoken with your colleague on this matter, link but there we raised the issue of migrating our project to your repository, so I decided to create a new ticket for this error. The main project of our work: link

makssent avatar Oct 02 '24 16:10 makssent

This is not just a simple question or a bug report. Seeking help for debugging your own code issues through GitHub issues can be quite challenging. Is this a request from your company or a personal interest, and does the company's request consider the commercial viability of the service?

terrymanu avatar Oct 03 '24 07:10 terrymanu

This is not just a simple question or a bug report. Seeking help for debugging your own code issues through GitHub issues can be quite challenging.

Is this a request from your company or a personal interest, and does the company's request consider the commercial viability of the service?

Regarding the error, this request raise is only my personal question. Regarding: "does the company's request consider the commercial viability of the service?" can you describe in more detail what is meant by this? I didn't quite understand what it was about.

Specifically at this moment, I'm speaking not on behalf of the company but as an individual. I've created a ticket with the aim of getting assistance in resolving the error. Another question regarding the company migration I didn't want to bring up; it's relevant, but it's currently outside my responsibilities. If it's possible, please inform me about it, and I'll notify others who are more competent in this matter.

makssent avatar Oct 03 '24 08:10 makssent

This is not just a simple question or a bug report. Seeking help for debugging your own code issues through GitHub issues can be quite challenging. Is this a request from your company or a personal interest, and does the company's request consider the commercial viability of the service?

Regarding the error, this request raise is only my personal question. Regarding: "does the company's request consider the commercial viability of the service?" can you describe in more detail what is meant by this? I didn't quite understand what it was about.

Specifically at this moment, I'm speaking not on behalf of the company but as an individual. I've created a ticket with the aim of getting assistance in resolving the error. Another question regarding the company migration I didn't want to bring up; it's relevant, but it's currently outside my responsibilities. If it's possible, please inform me about it, and I'll notify others who are more competent in this matter.

The open-source version of ShardingSphere has a corresponding commercial version with powerful features, and you can give it a try.

https://sphere-ex.com/ https://docs.sphere-ex.com/sphereex-dbplussuite/latest/docs/overview/different/

thicv avatar Oct 09 '24 00:10 thicv

This is not just a simple question or a bug report. Seeking help for debugging your own code issues through GitHub issues can be quite challenging. Is this a request from your company or a personal interest, and does the company's request consider the commercial viability of the service?

Regarding the error, this request raise is only my personal question. Regarding: "does the company's request consider the commercial viability of the service?" can you describe in more detail what is meant by this? I didn't quite understand what it was about. Specifically at this moment, I'm speaking not on behalf of the company but as an individual. I've created a ticket with the aim of getting assistance in resolving the error. Another question regarding the company migration I didn't want to bring up; it's relevant, but it's currently outside my responsibilities. If it's possible, please inform me about it, and I'll notify others who are more competent in this matter.

The open-source version of ShardingSphere has a corresponding commercial version with powerful features, and you can give it a try.

https://sphere-ex.com/ https://docs.sphere-ex.com/sphereex-dbplussuite/latest/docs/overview/different/

I don't think I need it.

makssent avatar Oct 09 '24 09:10 makssent

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.

github-actions[bot] avatar Oct 16 '24 20:10 github-actions[bot]