You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "YoungRX (via GitHub)" <gi...@apache.org> on 2023/03/09 10:40:07 UTC

[GitHub] [arrow] YoungRX opened a new issue, #34515: [C++] How to use predicate pushdown of binary and decimal types in arrow::parquet?

YoungRX opened a new issue, #34515:
URL: https://github.com/apache/arrow/issues/34515

   ### Describe the usage question you have. Please include as many useful details as  possible.
   
   
   I am using 8.0.0. When I set a predicate pushdown expression on some types, I get an error. 
   These types include `timestamp`, `date32`, `fixed_size_binary`, `string`, `binary`. 
   
   The error occurs in the following code:
   ```
   scanOptions->filter = 
           arrow::compute::and_(predicate_filter_expressions).Bind(*scanOptions->dataset_schema).ValueOrDie();
   ```
   
   The error information about `date32` is as follows:
   
   > 0xffff4c1b7218 "Function 'greater' has no kernel matching input types (array[date32[day]], scalar[int32])
   > /shared/cx_obs_data/softwares/arrow/cpp/src/arrow/compute/exec/expression.cc:388  call.function->DispatchBest("...
   
   The error information of other types is the same as the above. It seems that the related function is not implemented.
   
   Do versions later than 8.0.0 support predicate pushdown of these types? 
   Or do you have plans to add implementations of predicate pushdown of these types?
   
   In addition, how to build `Expression literal` for the decimal128 type?
   I use `arrow::compute::literal(arrow::Datum(std::forward<char*>(result)))` and it reports an error.
   Alternatively, the decimal128 type does not implement predicate pushdown either.
   
   
   
   ### Component(s)
   
   C++


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on issue #34515: [C++] How to use predicate pushdown of binary and decimal types in arrow::parquet?

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on issue #34515:
URL: https://github.com/apache/arrow/issues/34515#issuecomment-1468473413

   Can you share `predicate_filter_expressions`?  It sounds like you have a filter like `field_ref("timestamp_col") > 17` and you perhaps want something like `field_ref("timestamp_col") > literal(std::make_shared<TimestampScalar>(timestamp(), 17))`?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] YoungRX commented on issue #34515: [C++] How to use predicate pushdown of binary and decimal types in arrow::parquet?

Posted by "YoungRX (via GitHub)" <gi...@apache.org>.
YoungRX commented on issue #34515:
URL: https://github.com/apache/arrow/issues/34515#issuecomment-1469205185

   Yes. But I use `arrow::Datum(std::forward<int64_t>(timestamp_value));` as a literal.
   The specific code is as follows:
   ```
       if (strcmp(opName, ">") == 0) {
           predicate_filter.push_back(arrow::compute::greater(
               arrow::compute::field_ref(colField->name()),
               arrow::compute::literal(arrow::Datum(std::forward<int64_t>(timestamp_value)))
           ));
   ```
   According to the example you gave:
   ```
       if (strcmp(opName, ">") == 0) {
           predicate_filter.push_back(arrow::compute::greater(
               arrow::compute::field_ref("timestamp_col"),
               arrow::compute::literal(arrow::Datum(std::forward<int64_t>(17)))
           ));
   ```
   Then, an error is reported when Bind() is used.
   
   If I use `literal(std::make_shared<TimestampScalar>(timestamp(), 17))`, is the problem likely to be solved? What about the other types?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] YoungRX commented on issue #34515: [C++] How to use predicate pushdown of binary and decimal types in arrow::parquet?

Posted by "YoungRX (via GitHub)" <gi...@apache.org>.
YoungRX commented on issue #34515:
URL: https://github.com/apache/arrow/issues/34515#issuecomment-1478820120

   I see. Thanks a lot.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] westonpace commented on issue #34515: [C++] How to use predicate pushdown of binary and decimal types in arrow::parquet?

Posted by "westonpace (via GitHub)" <gi...@apache.org>.
westonpace commented on issue #34515:
URL: https://github.com/apache/arrow/issues/34515#issuecomment-1478187823

   If I use literal(std::make_shared<TimestampScalar>(timestamp(), 17)), is the problem likely to be solved?
   
   Yes.  Full example:
   
   ```
   // Licensed to the Apache Software Foundation (ASF) under one
   // or more contributor license agreements.  See the NOTICE file
   // distributed with this work for additional information
   // regarding copyright ownership.  The ASF licenses this file
   // to you under the Apache License, Version 2.0 (the
   // "License"); you may not use this file except in compliance
   // with the License.  You may obtain a copy of the License at
   //
   //   http://www.apache.org/licenses/LICENSE-2.0
   //
   // Unless required by applicable law or agreed to in writing,
   // software distributed under the License is distributed on an
   // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   // KIND, either express or implied.  See the License for the
   // specific language governing permissions and limitations
   // under the License.
   
   #include <arrow/io/api.h>
   #include <arrow/array/builder_primitive.h>
   #include <arrow/array/builder_binary.h>
   #include <arrow/compute/api.h>
   #include <arrow/compute/exec/exec_plan.h>
   #include <arrow/compute/exec/options.h>
   #include <arrow/result.h>
   #include <arrow/status.h>
   #include <arrow/table.h>
   #include <parquet/arrow/writer.h>
   
   #include <iostream>
   
   using arrow::Result;
   using arrow::Status;
   
   namespace
   {
   
     static constexpr int32_t kNumVals = 1000000;
   
     Result<std::shared_ptr<arrow::Array>> ValuesArray()
     {
       arrow::Int64Builder builder;
       ARROW_RETURN_NOT_OK(builder.Reserve(kNumVals));
       for (int32_t i = 0; i < kNumVals; i++)
       {
         ARROW_RETURN_NOT_OK(builder.Append(i));
       }
       return builder.Finish();
     }
   
     Status DoTheThing()
     {
       std::shared_ptr<arrow::DataType> ns_timestamp = arrow::timestamp(arrow::TimeUnit::NANO);
       ARROW_ASSIGN_OR_RAISE(std::shared_ptr<arrow::Array> array, ValuesArray());
       ARROW_ASSIGN_OR_RAISE(arrow::Datum timestamps, arrow::compute::Cast(array, ns_timestamp));
       std::shared_ptr<arrow::RecordBatch> batch = arrow::RecordBatch::Make(
           arrow::schema({arrow::field("times", ns_timestamp)}),
           kNumVals,
           {timestamps.array()});
   
       arrow::compute::Expression timestamp_17 =
           arrow::compute::literal(std::make_shared<arrow::TimestampScalar>(17, ns_timestamp));
   
       arrow::compute::Expression gt_17 = arrow::compute::call("greater", {arrow::compute::field_ref(0), timestamp_17});
       ARROW_ASSIGN_OR_RAISE(gt_17, gt_17.Bind(*batch->schema()));
   
       ARROW_ASSIGN_OR_RAISE(arrow::Datum mask,
                             arrow::compute::ExecuteScalarExpression(gt_17, *batch->schema(), arrow::Datum(batch)));
   
       ARROW_ASSIGN_OR_RAISE(arrow::Datum filtered, arrow::compute::Filter(array, mask));
   
       std::cout << "There were " << timestamps.length() << " values and the filtered reduced it to " << filtered.length() << std::endl;
       return Status::OK();
     }
   
   } // namespace
   
   int main()
   {
     Status st = DoTheThing();
     if (!st.ok())
     {
       std::cerr << st << std::endl;
       return 1;
     }
     return 0;
   }
   ```
   
   > What about the other types?
   
   Every data type has a corresponding scalar type.  Literals are typed.  You should create a literal of the appropriate type.  Some type mismatches we can handle with implicit casting but int64->timestamp is not one of those.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] YoungRX closed issue #34515: [C++] How to use predicate pushdown of binary and decimal types in arrow::parquet?

Posted by "YoungRX (via GitHub)" <gi...@apache.org>.
YoungRX closed issue #34515: [C++] How to use predicate pushdown of binary and decimal types in arrow::parquet?
URL: https://github.com/apache/arrow/issues/34515


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org