1{ lib
2, stdenv
3, buildPythonPackage
4, fetchFromGitHub
5, rustPlatform
6, pytestCheckHook
7, libiconv
8, numpy
9, protobuf
10, pyarrow
11, Security
12}:
13
14let
15 arrow-testing = fetchFromGitHub {
16 name = "arrow-testing";
17 owner = "apache";
18 repo = "arrow-testing";
19 rev = "5bab2f264a23f5af68f69ea93d24ef1e8e77fc88";
20 hash = "sha256-Pxx8ohUpXb5u1995IvXmxQMqWiDJ+7LAll/AjQP7ph8=";
21 };
22
23 parquet-testing = fetchFromGitHub {
24 name = "parquet-testing";
25 owner = "apache";
26 repo = "parquet-testing";
27 rev = "e13af117de7c4f0a4d9908ae3827b3ab119868f3";
28 hash = "sha256-rVI9zyk9IRDlKv4u8BeMb0HRdWLfCpqOlYCeUdA7BB8=";
29 };
30in
31
32buildPythonPackage rec {
33 pname = "datafusion";
34 version = "25.0.0";
35 format = "pyproject";
36
37 src = fetchFromGitHub {
38 name = "datafusion-source";
39 owner = "apache";
40 repo = "arrow-datafusion-python";
41 rev = "refs/tags/${version}";
42 hash = "sha256-oC+fp41a9rsdobpvShZ7sDdtYPJQQ7JLg6MFL+4Pksg=";
43 };
44
45 cargoDeps = rustPlatform.fetchCargoTarball {
46 name = "datafusion-cargo-deps";
47 inherit src pname version;
48 hash = "sha256-0e0ZRgwcS/46mi4c2loAnBA2bsaD+/RiMh7oNg3EvHY=";
49 };
50
51 nativeBuildInputs = with rustPlatform; [
52 cargoSetupHook
53 maturinBuildHook
54 ];
55
56 buildInputs = [ protobuf ] ++ lib.optionals stdenv.isDarwin [ libiconv Security ];
57
58 propagatedBuildInputs = [ pyarrow ];
59
60 nativeCheckInputs = [ pytestCheckHook numpy ];
61 pythonImportsCheck = [ "datafusion" ];
62 pytestFlagsArray = [ "--pyargs" pname ];
63
64 preCheck = ''
65 pushd $TMPDIR
66 ln -s ${arrow-testing} ./testing
67 ln -s ${parquet-testing} ./parquet
68 '';
69
70 postCheck = ''
71 popd
72 '';
73
74 meta = with lib; {
75 description = "Extensible query execution framework";
76 longDescription = ''
77 DataFusion is an extensible query execution framework, written in Rust,
78 that uses Apache Arrow as its in-memory format.
79 '';
80 homepage = "https://arrow.apache.org/datafusion/";
81 changelog = "https://github.com/apache/arrow-datafusion-python/blob/${version}/CHANGELOG.md";
82 license = with licenses; [ asl20 ];
83 maintainers = with maintainers; [ cpcloud ];
84 };
85}