-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #201: Fixed 'ORDER BY' clause problems
- Loading branch information
1 parent
d2b3f6b
commit e03748c
Showing
6 changed files
with
512 additions
and
426 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...pter/src/main/java/com/exasol/adapter/dialects/bigquery/BigQuerySqlGenerationVisitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.exasol.adapter.dialects.bigquery; | ||
|
||
import com.exasol.adapter.*; | ||
import com.exasol.adapter.dialects.*; | ||
import com.exasol.adapter.sql.*; | ||
|
||
import java.util.*; | ||
|
||
/** | ||
* This class implements a Google-Big-Query-specific variant of a SQL generation visitor. | ||
*/ | ||
public class BigQuerySqlGenerationVisitor extends SqlGenerationVisitor { | ||
/** | ||
* Create a new instance of {@link BigQuerySqlGenerationVisitor}. | ||
* | ||
* @param dialect SQL dialect | ||
* @param context SQL generation context | ||
*/ | ||
public BigQuerySqlGenerationVisitor(final SqlDialect dialect, final SqlGenerationContext context) { | ||
super(dialect, context); | ||
} | ||
|
||
@Override | ||
public String visit(final SqlOrderBy orderBy) throws AdapterException { | ||
final List<String> sqlOrderElement = new ArrayList<>(); | ||
for (int i = 0; i < orderBy.getExpressions().size(); ++i) { | ||
final boolean isAscending = orderBy.isAscending().get(i); | ||
final String elementSql = orderBy.getExpressions().get(i).accept(this) + (isAscending ? "" : " DESC"); | ||
sqlOrderElement.add(elementSql); | ||
} | ||
return "ORDER BY " + String.join(", ", sqlOrderElement); | ||
} | ||
} |
Oops, something went wrong.