use of io.questdb.griffin.model.ExpressionNode in project questdb by bluestreak01.
the class WhereClauseParser method analyzeNotListOfValues.
private void analyzeNotListOfValues(IntrinsicModel model, CharSequence columnName, RecordMetadata meta, ExpressionNode node, ExpressionNode notNode) {
final int columnIndex = meta.getColumnIndex(columnName);
boolean newColumn = true;
boolean preferred = Chars.equalsIgnoreCaseNc(preferredKeyColumn, columnName);
if (preferred || (preferredKeyColumn == null && meta.isColumnIndexed(columnIndex))) {
if (model.keyColumn != null && (newColumn = !Chars.equals(model.keyColumn, columnName)) && meta.getIndexValueBlockCapacity(columnIndex) <= meta.getIndexValueBlockCapacity(model.keyColumn)) {
return;
}
int i = node.paramCount - 1;
tempKeys.clear();
tempPos.clear();
// if any of values is not an indexed constant - bail out
if (i == 1) {
if (node.rhs == null || node.rhs.type != ExpressionNode.CONSTANT) {
return;
}
if (tempKeys.add(unquote(node.rhs.token))) {
tempPos.add(node.position);
}
} else {
for (i--; i > -1; i--) {
ExpressionNode c = node.args.getQuick(i);
if (c.type != ExpressionNode.CONSTANT) {
return;
}
if (isNullKeyword(c.token)) {
if (tempKeys.add(null)) {
tempPos.add(c.position);
}
} else {
if (tempKeys.add(unquote(c.token))) {
tempPos.add(c.position);
}
}
}
}
// and reset intrinsic values on nodes associated with old column
if (newColumn) {
model.keyExcludedValues.clear();
model.keyExcludedValuePositions.clear();
model.keyExcludedValues.addAll(tempKeys);
model.keyExcludedValuePositions.addAll(tempPos);
revertProcessedNodes(keyExclNodes, model, columnName, notNode);
return;
} else {
if (model.keyExcludedValues.size() == 0) {
model.keyExcludedValues.addAll(tempKeys);
model.keyExcludedValuePositions.addAll(tempPos);
}
}
if (model.keySubQuery == null) {
// calculate overlap of values
replaceAllWithOverlap(model, false);
keyExclNodes.add(notNode);
notNode.intrinsicValue = IntrinsicModel.TRUE;
}
}
}
use of io.questdb.griffin.model.ExpressionNode in project questdb by bluestreak01.
the class WhereClauseParser method analyzeIn.
private boolean analyzeIn(AliasTranslator translator, IntrinsicModel model, ExpressionNode node, RecordMetadata metadata, FunctionParser functionParser, SqlExecutionContext executionContext) throws SqlException {
if (node.paramCount < 2) {
throw SqlException.$(node.position, "Too few arguments for 'in'");
}
ExpressionNode col = node.paramCount < 3 ? node.lhs : node.args.getLast();
if (col.type != ExpressionNode.LITERAL) {
return false;
}
CharSequence column = translator.translateAlias(col.token);
if (metadata.getColumnIndexQuiet(column) == -1) {
throw SqlException.invalidColumn(col.position, col.token);
}
return analyzeInInterval(model, col, node, false, functionParser, metadata, executionContext) || analyzeListOfValues(model, column, metadata, node) || analyzeInLambda(model, column, metadata, node);
}
Aggregations