本文整理匯總了Java中com.foundationdb.sql.parser.CursorNode類的典型用法代碼示例。如果您正苦於以下問題:Java CursorNode類的具體用法?Java CursorNode怎麽用?Java CursorNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CursorNode類屬於com.foundationdb.sql.parser包,在下文中一共展示了CursorNode類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visit
import com.foundationdb.sql.parser.CursorNode; //導入依賴的package包/類
@Override
public Visitable visit(Visitable visitable)
throws SqlTranslationException {
QueryTreeNode node = (QueryTreeNode) visitable;
if (visitable instanceof SelectNode) {
SelectNode snode = (SelectNode) node;
selectNode = snode;
}
int type = node.getNodeType();
switch (type) {
case NodeTypes.CURSOR_NODE: {
cursorNode = (CursorNode) node;
}
break;
default:
}
return node;
}
示例2: testGroupByCheckSuccess
import com.foundationdb.sql.parser.CursorNode; //導入依賴的package包/類
@Test
public void testGroupByCheckSuccess() {
String sql = "select count(clickcount_ag) as \"clickcount_ag\", testDim from tabletest group by testDim order by count(clickcount_ag) limit 100";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
Mockito.CALLS_REAL_METHODS);
QueryDescription queryDesc = sqlTranslator.parse(sql);
SelectNode selectNode = queryDesc.getSelectNode();
CursorNode cursorNode = queryDesc.getCursorNode();
Map<String, String> columnsMap = new HashMap<String, String>();
columnsMap.put("testdim", "testdim");
try {
sqlTranslator.groupByCheck(selectNode, cursorNode, columnsMap);
} catch (SqlTranslationException ex) {
fail("expected SqlTranslationException");
}
}
示例3: testGroupByOrderBy
import com.foundationdb.sql.parser.CursorNode; //導入依賴的package包/類
@Test
public void testGroupByOrderBy() {
String sql = "select count(clickcount_ag) as \"clickcount_ag\", testDim from tabletest order by count(clickcount_ag) limit 100";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
Mockito.CALLS_REAL_METHODS);
QueryDescription queryDesc = sqlTranslator.parse(sql);
SelectNode selectNode = queryDesc.getSelectNode();
CursorNode cursorNode = queryDesc.getCursorNode();
Map<String, String> columnsMap = new HashMap<String, String>();
columnsMap.put("testdim", "testdim");
try {
sqlTranslator.groupByCheck(selectNode, cursorNode, columnsMap);
fail("expected SqlTranslationException");
} catch (SqlTranslationException ex) {
assertTrue(true);
}
}
示例4: testGroupByError
import com.foundationdb.sql.parser.CursorNode; //導入依賴的package包/類
@Test
public void testGroupByError() {
String sql = "select count(clickcount_ag) as \"clickcount_ag\", testDim from tabletest group by testDim order by count(clickcount_ag) limit 100";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
Mockito.CALLS_REAL_METHODS);
QueryDescription queryDesc = sqlTranslator.parse(sql);
SelectNode selectNode = queryDesc.getSelectNode();
CursorNode cursorNode = queryDesc.getCursorNode();
Map<String, String> columnsMap = new HashMap<String, String>();
try {
sqlTranslator.groupByCheck(selectNode, cursorNode, columnsMap);
fail("expected SqlTranslationException");
} catch (SqlTranslationException ex) {
assertTrue(true);
}
}
示例5: addLimitCondtionForSelectSQL
import com.foundationdb.sql.parser.CursorNode; //導入依賴的package包/類
public static String addLimitCondtionForSelectSQL(RouteResultset rrs,
CursorNode cursNode, int defaultMaxLimit)
throws SQLSyntaxErrorException {
NumericConstantNode offCountNode = new NumericConstantNode();
offCountNode.setNodeType(NodeTypes.INT_CONSTANT_NODE);
offCountNode.setValue(defaultMaxLimit);
cursNode.init(cursNode.statementToString(),
cursNode.getResultSetNode(), cursNode.getName(),
cursNode.getOrderByList(), cursNode.getOffsetClause(),
offCountNode, cursNode.getUpdateMode(),
cursNode.getUpdatableColumns());
rrs.setLimitSize(defaultMaxLimit);
try {
return new NodeToString().toString(cursNode);
} catch (StandardException e) {
throw new SQLSyntaxErrorException(e);
}
}
示例6: addLimitCondtionForSelectSQL
import com.foundationdb.sql.parser.CursorNode; //導入依賴的package包/類
public static String addLimitCondtionForSelectSQL(RouteResultset rrs,
CursorNode cursNode, int defaultMaxLimit) throws SQLSyntaxErrorException {
NumericConstantNode offCountNode = new NumericConstantNode();
offCountNode.setNodeType(NodeTypes.INT_CONSTANT_NODE);
offCountNode.setValue(defaultMaxLimit);
cursNode.init(cursNode.statementToString(),
cursNode.getResultSetNode(), cursNode.getName(),
cursNode.getOrderByList(), cursNode.getOffsetClause(),
offCountNode, cursNode.getUpdateMode(),
cursNode.getUpdatableColumns());
rrs.setLimitSize(defaultMaxLimit);
try {
return new NodeToString().toString(cursNode);
} catch (StandardException e) {
throw new SQLSyntaxErrorException(e);
}
}
示例7: findAndSetTypes
import com.foundationdb.sql.parser.CursorNode; //導入依賴的package包/類
/** Run just enough rules to get to TypeResolver, then set types. */
protected void findAndSetTypes(AISViewDefinition view) {
FromSubquery fromSubquery = view.getSubquery();
// put the SELECT in a cursorNode to enable bindAndTransform/statementLoader/etc on it.
CursorNode cursorNode = new CursorNode();
cursorNode.init("SELECT",
fromSubquery.getSubquery(),
view.getName().getFullTableName(),
fromSubquery.getOrderByList(),
fromSubquery.getOffset(),
fromSubquery.getFetchFirst(),
UpdateMode.UNSPECIFIED,
null);
cursorNode.setNodeType(NodeTypes.CURSOR_NODE);
bindAndTransform(cursorNode);
copyExposedNames(fromSubquery.getResultColumns(), fromSubquery.getSubquery().getResultColumns());
fromSubquery.setResultColumns(fromSubquery.getSubquery().getResultColumns());
PlanContext plan = new PlanContext(this);
plan.setPlan(new AST(cursorNode, null));
// can't user OperatorCompiler.compile, because it expects to return BasePlannable
ASTStatementLoader stmtLoader = new ASTStatementLoader();
stmtLoader.apply(plan);
TypeResolver typeResolver = new TypeResolver();
typeResolver.apply(plan);
copyTypes((ResultSet) ((SelectQuery)plan.getPlan()).getInput(), fromSubquery.getResultColumns());
}
示例8: testGroupByCheck
import com.foundationdb.sql.parser.CursorNode; //導入依賴的package包/類
@Test
public void testGroupByCheck() {
String sql = "select sum(gmv_ag) as gmv,_cpgnname from testTable group by _cpgnname having sum(gmv_ag) >0 limit 300";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
Mockito.CALLS_REAL_METHODS);
QueryDescription queryDesc = sqlTranslator.parse(sql);
SelectNode selectNode = queryDesc.getSelectNode();
TableDimension dimension = new TableDimension();
dimension.setName("testDim");
dimension.setType(0);
dimension.setMultiValue(true);
assertEquals("testDim", dimension.getName());
assertEquals(0, dimension.getType());
Table table = new Table();
table.setTableName("tabletest");
table.setNoInnerJoin(false);
table.setDateColumn("testDate");
table.setDimensions(Lists.newArrayList(dimension));
CursorNode cursorNode = queryDesc.getCursorNode();
Map<String, String> columnsMap = new HashMap<String, String>();
columnsMap.put("gmv", "gmv");
try {
sqlTranslator.groupByCheck(selectNode, cursorNode, columnsMap);
fail("expected SqlTranslationException");
} catch (SqlTranslationException ex) {
assertTrue(true);
}
}
示例9: addSQLLmit
import com.foundationdb.sql.parser.CursorNode; //導入依賴的package包/類
private static String addSQLLmit(SchemaConfig schema, RouteResultset rrs,
QueryTreeNode ast, String sql) throws SQLSyntaxErrorException {
if (!rrs.hasPrimaryKeyToCache() && schema.getDefaultMaxLimit() != -1
&& ast instanceof CursorNode
&& ((CursorNode) ast).getFetchFirstClause() == null) {
String newstmt = SelectSQLAnalyser.addLimitCondtionForSelectSQL(
rrs, (CursorNode) ast, schema.getDefaultMaxLimit());
if (newstmt != null) {
return newstmt;
}
}
return sql;
}
示例10: addSQLLmit
import com.foundationdb.sql.parser.CursorNode; //導入依賴的package包/類
private static String addSQLLmit(SchemaConfig schema, RouteResultset rrs,
QueryTreeNode ast, String sql) throws SQLSyntaxErrorException {
if (!rrs.hasPrimaryKeyToCache()&&schema.getDefaultMaxLimit() != -1 && ast instanceof CursorNode
&& ((CursorNode) ast).getFetchFirstClause() == null) {
String newstmt = SelectSQLAnalyser.addLimitCondtionForSelectSQL(
rrs, (CursorNode) ast, schema.getDefaultMaxLimit());
if (newstmt != null) {
return newstmt;
}
}
return sql;
}
示例11: getCursorNode
import com.foundationdb.sql.parser.CursorNode; //導入依賴的package包/類
/**
* @return the cursorNode
*/
public CursorNode getCursorNode() {
return cursorNode;
}
示例12: groupByCheck
import com.foundationdb.sql.parser.CursorNode; //導入依賴的package包/類
public void groupByCheck(SelectNode selectNode, CursorNode cursorNode, Map<String, String> columnsMap) {
OrderByList orderByList = cursorNode.getOrderByList();
GroupByList groupByList = selectNode.getGroupByList();
if (groupByList == null || groupByList.size() == 0) {
if((orderByList !=null && orderByList.size() > 0)) {
throw new SqlTranslationException(
ExceptionErrorCode.SQL_PARSING_ERROR
.getErrorMessage()
+ "'Order By can only be used with Group By.' ");
}
if (columnsMap.size() > 0) {
throw new SqlTranslationException(
ExceptionErrorCode.INVALID_AGGREGATE.getErrorMessage()
+ "Group By columns required for dimensions: "
+ columnsMap.values());
}
} else {
Set<String> groupByColSet = Sets.newHashSet();
int listSize = groupByList.size();
for (int i = 0; i < listSize; i++) {
GroupByColumn groupByCol = (GroupByColumn) groupByList.get(i);
ValueNode vNode = groupByCol.getColumnExpression();
if (vNode instanceof ColumnReference) {
ColumnReference column = (ColumnReference) vNode;
String colName = column.getColumnName();
if (!columnsMap.containsKey(colName)) {
throw new SqlTranslationException(
ExceptionErrorCode.INVALID_AGGREGATE
.getErrorMessage()
+ "Group By column not found in Selection: "
+ colName);
}
groupByColSet.add(colName);
} else {
throw new SqlTranslationException(
ExceptionErrorCode.INVALID_AGGREGATE.getErrorMessage()
+ "No column refernce found for Group By.");
}
}
for (Map.Entry<String, String> entry : columnsMap.entrySet()) {
String key = entry.getKey();
if (!groupByColSet.contains(key)) {
throw new SqlTranslationException(
ExceptionErrorCode.INVALID_AGGREGATE
.getErrorMessage()
+ "Group By column required for dimension in Selection: "
+ key);
}
}
}
}
示例13: QueryDescription
import com.foundationdb.sql.parser.CursorNode; //導入依賴的package包/類
/**
* @param statement
* @param fromTable
* @param fields
*/
public QueryDescription(CursorNode cursorNode, SelectNode selectNode) {
this.cursorNode = cursorNode;
this.selectNode = selectNode;
}