@@ -1290,6 +1290,84 @@ BuilderExpr BuilderExpr::logicalOr(const BuilderExpr& rhs) const {
1290
1290
}
1291
1291
}
1292
1292
1293
+ BuilderExpr BuilderExpr::bwAnd (const BuilderExpr& rhs) const {
1294
+ try {
1295
+ auto bin_oper = Analyzer::normalizeOperExpr (
1296
+ OpType::kBwAnd , Qualifier::kOne , expr_, rhs.expr (), nullptr );
1297
+ return {builder_, bin_oper, " " , true };
1298
+ } catch (std::runtime_error& e) {
1299
+ throw InvalidQueryError () << " Cannot apply BW_AND operation for operand types "
1300
+ << expr_->type ()->toString () << " and "
1301
+ << rhs.expr ()->type ()->toString ();
1302
+ }
1303
+ }
1304
+
1305
+ BuilderExpr BuilderExpr::bwAnd (int val) const {
1306
+ return bwAnd (builder_->cst (val, builder_->ctx_ .int32 (false )));
1307
+ }
1308
+
1309
+ BuilderExpr BuilderExpr::bwAnd (int64_t val) const {
1310
+ return bwAnd (builder_->cst (val, builder_->ctx_ .int64 (false )));
1311
+ }
1312
+
1313
+ BuilderExpr BuilderExpr::bwOr (const BuilderExpr& rhs) const {
1314
+ try {
1315
+ auto bin_oper = Analyzer::normalizeOperExpr (
1316
+ OpType::kBwOr , Qualifier::kOne , expr_, rhs.expr (), nullptr );
1317
+ return {builder_, bin_oper, " " , true };
1318
+ } catch (std::runtime_error& e) {
1319
+ throw InvalidQueryError () << " Cannot apply BW_OR operation for operand types "
1320
+ << expr_->type ()->toString () << " and "
1321
+ << rhs.expr ()->type ()->toString ();
1322
+ }
1323
+ }
1324
+
1325
+ BuilderExpr BuilderExpr::bwOr (int val) const {
1326
+ return bwOr (builder_->cst (val, builder_->ctx_ .int32 (false )));
1327
+ }
1328
+
1329
+ BuilderExpr BuilderExpr::bwOr (int64_t val) const {
1330
+ return bwOr (builder_->cst (val, builder_->ctx_ .int64 (false )));
1331
+ }
1332
+
1333
+ BuilderExpr BuilderExpr::bwXor (const BuilderExpr& rhs) const {
1334
+ try {
1335
+ auto bin_oper = Analyzer::normalizeOperExpr (
1336
+ OpType::kBwXor , Qualifier::kOne , expr_, rhs.expr (), nullptr );
1337
+ return {builder_, bin_oper, " " , true };
1338
+ } catch (std::runtime_error& e) {
1339
+ throw InvalidQueryError () << " Cannot apply BW_XOR operation for operand types "
1340
+ << expr_->type ()->toString () << " and "
1341
+ << rhs.expr ()->type ()->toString ();
1342
+ }
1343
+ }
1344
+
1345
+ BuilderExpr BuilderExpr::bwXor (int val) const {
1346
+ return bwXor (builder_->cst (val, builder_->ctx_ .int32 (false )));
1347
+ }
1348
+
1349
+ BuilderExpr BuilderExpr::bwXor (int64_t val) const {
1350
+ return bwXor (builder_->cst (val, builder_->ctx_ .int64 (false )));
1351
+ }
1352
+
1353
+ BuilderExpr BuilderExpr::bwNot () const {
1354
+ if (!expr_->type ()->isInteger ()) {
1355
+ throw InvalidQueryError (" Only integer expressions are allowed for BW_NOT operation." );
1356
+ }
1357
+
1358
+ if (expr_->is <Constant>()) {
1359
+ auto cst_expr = expr_->as <Constant>();
1360
+ if (cst_expr->isNull ()) {
1361
+ return *this ;
1362
+ }
1363
+ return builder_->cst (~cst_expr->intVal (), cst_expr->type ());
1364
+ }
1365
+
1366
+ auto uoper =
1367
+ makeExpr<UOper>(expr_->type (), expr_->containsAgg (), OpType::kBwNot , expr_);
1368
+ return {builder_, uoper, " " , true };
1369
+ }
1370
+
1293
1371
BuilderExpr BuilderExpr::eq (const BuilderExpr& rhs) const {
1294
1372
try {
1295
1373
auto bin_oper = Analyzer::normalizeOperExpr (
0 commit comments