Skip to content

Commit

Permalink
Fixes build error with apache-arrow 16 (#1882)
Browse files Browse the repository at this point in the history
Fixes #1881

Signed-off-by: Tao He <linzhu.ht@alibaba-inc.com>
  • Loading branch information
sighingnow authored Apr 25, 2024
1 parent 3e91a0b commit e8b8c82
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ jobs:
wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
sudo apt update
sudo apt install -y libarrow-dev=14.0.1-1 \
libarrow-dataset-dev=14.0.1-1 \
libarrow-acero-dev=14.0.1-1 \
libarrow-flight-dev=14.0.1-1 \
libgandiva-dev=14.0.1-1 \
libparquet-dev=14.0.1-1
sudo apt install -y libarrow-dev \
libarrow-dataset-dev \
libarrow-acero-dev \
libarrow-flight-dev \
libgandiva-dev \
libparquet-dev
# install deps for java
sudo apt install -y default-jdk-headless maven
Expand Down
12 changes: 12 additions & 0 deletions modules/io/io/io_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ limitations under the License.

#include "arrow/api.h"
#include "arrow/io/api.h"
#include "arrow/util/config.h"
#include "arrow/util/uri.h"
#include "boost/algorithm/string.hpp"

Expand Down Expand Up @@ -72,10 +73,16 @@ std::unique_ptr<IIOAdaptor> IOFactory::CreateIOAdaptor(
}
// If there are non-ascii characters, we shall pre-encode the location,
// as the arrow::internal::Uri will fail.
#if defined(ARROW_VERSION) && ARROW_VERSION >= 16000000
auto encoded_location = location_to_parse.substr(0, i) +
arrow::util::UriEscape(location_to_parse.substr(i));
arrow::util::Uri uri;
#else
auto encoded_location =
location_to_parse.substr(0, i) +
arrow::internal::UriEscape(location_to_parse.substr(i));
arrow::internal::Uri uri;
#endif
{
auto s = uri.Parse(encoded_location);
if (!s.ok()) { // Assume it's a local file
Expand All @@ -100,8 +107,13 @@ std::unique_ptr<IIOAdaptor> IOFactory::CreateIOAdaptor(
// Note we should not encode the leading '/' if there is one,
// cause arrow::internal::Uri requires the path must be an absolute path.
location_to_parse = std::string(resolved_path);
#if defined(ARROW_VERSION) && ARROW_VERSION >= 16000000
auto s = uri.Parse("file:///" +
arrow::util::UriEscape(location_to_parse.substr(1)));
#else
auto s = uri.Parse(
"file:///" + arrow::internal::UriEscape(location_to_parse.substr(1)));
#endif
if (!s.ok()) {
LOG(ERROR) << "Failed to detect the scheme of given location "
<< location;
Expand Down
10 changes: 9 additions & 1 deletion modules/io/io/local_io_adaptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ limitations under the License.
#include "arrow/csv/api.h"
#include "arrow/filesystem/api.h"
#include "arrow/io/api.h"
#include "arrow/util/config.h"
#include "arrow/util/uri.h"
#include "boost/algorithm/string.hpp"

Expand Down Expand Up @@ -103,11 +104,18 @@ LocalIOAdaptor::LocalIOAdaptor(const std::string& location)
break;
}
}
#if defined(ARROW_VERSION) && ARROW_VERSION >= 16000000
auto encoded_location =
location_.substr(0, i) + arrow::util::UriEscape(location_.substr(i));
#else
auto encoded_location =
location_.substr(0, i) + arrow::internal::UriEscape(location_.substr(i));
#endif
fs_ = arrow::fs::FileSystemFromUriOrPath(encoded_location, &location_)
.ValueOrDie();
#if defined(ARROW_VERSION) && ARROW_VERSION >= 3000000
#if defined(ARROW_VERSION) && ARROW_VERSION >= 16000000
location_ = arrow::util::UriUnescape(location_);
#elif defined(ARROW_VERSION) && ARROW_VERSION >= 3000000
location_ = arrow::internal::UriUnescape(location_);
#else
// Referred https://stackoverflow.com/questions/154536/encode-decode-urls-in-c
Expand Down

0 comments on commit e8b8c82

Please sign in to comment.