| 1337 | } |
| 1338 | |
| 1339 | Status HdfsOrcScanner::PrepareSearchArguments() { |
| 1340 | if (!state_->query_options().orc_read_statistics) return Status::OK(); |
| 1341 | if (!ShouldUpdateSearchArgument()) return Status::OK(); |
| 1342 | VLOG_FILE << "Building SearchArgument on ORC file " << filename(); |
| 1343 | |
| 1344 | const TupleDescriptor* stats_tuple_desc = scan_node_->stats_tuple_desc(); |
| 1345 | if (!stats_tuple_desc) return Status::OK(); |
| 1346 | |
| 1347 | std::unique_ptr<orc::SearchArgumentBuilder> sarg = |
| 1348 | orc::SearchArgumentFactory::newBuilder(); |
| 1349 | bool sargs_supported = false; |
| 1350 | const orc::Type* node = nullptr; |
| 1351 | bool pos_field; |
| 1352 | bool missing_field; |
| 1353 | int num_pushed_down_predicates = 0; |
| 1354 | |
| 1355 | DCHECK_GE(stats_tuple_desc->slots().size(), stats_conjunct_evals_.size()); |
| 1356 | for (int i = 0; i < stats_conjunct_evals_.size(); ++i) { |
| 1357 | SlotDescriptor* slot_desc = stats_tuple_desc->slots()[i]; |
| 1358 | // Resolve column path to determine col idx in file schema. |
| 1359 | RETURN_IF_ERROR(schema_resolver_->ResolveColumn(slot_desc->col_path(), |
| 1360 | &node, &pos_field, &missing_field)); |
| 1361 | if (pos_field || missing_field) continue; |
| 1362 | |
| 1363 | ScalarExprEvaluator* eval = stats_conjunct_evals_[i]; |
| 1364 | const string& fn_name = eval->root().function_name(); |
| 1365 | if (fn_name == "is_null_pred" || fn_name == "is_not_null_pred") { |
| 1366 | PrepareIsNullPredicate(fn_name == "is_not_null_pred", node->getColumnId(), |
| 1367 | slot_desc->type(), sarg.get()); |
| 1368 | sargs_supported = true; |
| 1369 | num_pushed_down_predicates++; |
| 1370 | continue; |
| 1371 | } |
| 1372 | ScalarExpr* const_expr = eval->root().GetChild(1); |
| 1373 | // ORC reader only supports pushing down predicates whose constant parts are literal. |
| 1374 | // We could get non-literal expr if expr rewrites are disabled. |
| 1375 | if (!const_expr->IsLiteral()) continue; |
| 1376 | // TODO: push down stats predicates on CHAR/VARCHAR(IMPALA-10882) and |
| 1377 | // TIMESTAMP(IMPALA-10915) to ORC reader |
| 1378 | DCHECK(const_expr->type().type != TYPE_CHAR); |
| 1379 | DCHECK(const_expr->type().type != TYPE_VARCHAR); |
| 1380 | DCHECK(const_expr->type().type != TYPE_TIMESTAMP); |
| 1381 | DCHECK(slot_desc->type().type != TYPE_CHAR); |
| 1382 | DCHECK(slot_desc->type().type != TYPE_VARCHAR); |
| 1383 | DCHECK(slot_desc->type().type != TYPE_TIMESTAMP) << "FE should skip such predicates"; |
| 1384 | // TODO(IMPALA-10916): dealing with lhs that is a simple cast expr. |
| 1385 | if (GetOrcPredicateDataType(slot_desc->type()) != |
| 1386 | GetOrcPredicateDataType(const_expr->type())) { |
| 1387 | continue; |
| 1388 | } |
| 1389 | // Skip if the file schema contains unsupported types. |
| 1390 | // TODO: push down stats predicates on CHAR/VARCHAR(IMPALA-10882) and |
| 1391 | // TIMESTAMP(IMPALA-10915) to ORC reader |
| 1392 | if (node->getKind() == orc::CHAR |
| 1393 | || node->getKind() == orc::VARCHAR |
| 1394 | || node->getKind() == orc::TIMESTAMP) { |
| 1395 | continue; |
| 1396 | } |
nothing calls this directly
no test coverage detected