Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert语句转换存在ROW关键词问题 #2

Open
tangyibo opened this issue Nov 7, 2019 · 3 comments
Open

Insert语句转换存在ROW关键词问题 #2

tangyibo opened this issue Nov 7, 2019 · 3 comments

Comments

@tangyibo
Copy link

tangyibo commented Nov 7, 2019

您好,请教下下面的这个代码转换后的Insert语句存在row关键词,而当前大多数的oracle/mysql/postgresql数据库都不支持,请指教:

	public static void main(String[] args) {
		String sql="insert into dept (name, deptno) values ('a', 123) ,('b',345) ";
        SqlParser.Config config =SqlParser.configBuilder().setCaseSensitive(true).build();
        SqlParser parser = SqlParser.create(sql, config);
        SqlNode sqlNode =null;
        try {
				sqlNode=parser.parseStmt();
        }catch(SqlParseException e) {
        	e.printStackTrace();
        }
        System.out.println(sqlNode.toSqlString(OracleSqlDialect.DEFAULT));
        System.out.println("========================");
        System.out.println(sqlNode.toSqlString(PostgresqlSqlDialect.DEFAULT));
        System.out.println("========================");
        System.out.println(sqlNode.toSqlString(MysqlSqlDialect.DEFAULT));
	}

结果输出为:

INSERT INTO "DEPT" ("NAME", "DEPTNO")
VALUES ROW('a', 123),
ROW('b', 345)
========================
INSERT INTO "DEPT" ("NAME", "DEPTNO")
VALUES ROW('a', 123),
ROW('b', 345)
========================
INSERT INTO `DEPT` (`NAME`, `DEPTNO`)
VALUES ROW('a', 123),
ROW('b', 345)

但我期望的是:

INSERT INTO "DEPT" ("NAME", "DEPTNO")
VALUES ('a', 123),('b', 345)
========================
INSERT INTO "DEPT" ("NAME", "DEPTNO")
VALUES ('a', 123),('b', 345)
========================
INSERT INTO `DEPT` (`NAME`, `DEPTNO`)
VALUES ('a', 123),('b', 345)
@yuqi1129
Copy link
Owner

这是SqlRowOperatorunparse的默认行为, 默认会将方法名ROW带进去, 在calcite中 value后面是一个Row方法, 如果不想输出, 可以覆写该方法

@tangyibo
Copy link
Author

@yuqi1129 多谢,按照您的覆写已经成功实现。

@yuqi1129
Copy link
Owner

yuqi1129 commented Nov 14, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants