|
| 1 | +<!-- |
| 2 | + Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + or more contributor license agreements. See the NOTICE file |
| 4 | + distributed with this work for additional information |
| 5 | + regarding copyright ownership. The ASF licenses this file |
| 6 | + to you under the Apache License, Version 2.0 (the |
| 7 | + "License"); you may not use this file except in compliance |
| 8 | + with the License. You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | + Unless required by applicable law or agreed to in writing, |
| 13 | + software distributed under the License is distributed on an |
| 14 | + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + KIND, either express or implied. See the License for the |
| 16 | + specific language governing permissions and limitations |
| 17 | + under the License. |
| 18 | +--> |
| 19 | + |
| 20 | +# How to contribute |
| 21 | + |
| 22 | +Thanks for contributing this project! |
| 23 | + |
| 24 | +## Report your problems or requests |
| 25 | + |
| 26 | +Please file issues on the GitHub issue tracker: |
| 27 | +https://github.com/apache/arrow-flight-sql-postgresql/issues |
| 28 | + |
| 29 | +You can also use the following mailing lists: |
| 30 | + |
| 31 | +- `dev@arrow.apache.org`: for discussions about contributing to the |
| 32 | + project development. |
| 33 | +- `user@arrow.apache.org`: for questions on usage. |
| 34 | + |
| 35 | +See https://arrow.apache.org/community/#mailing-lists how to subscribe |
| 36 | +these mailing lists. |
| 37 | + |
| 38 | +## Build for development |
| 39 | + |
| 40 | +### Install dependencies |
| 41 | + |
| 42 | +You need to install the following dependencies before you build Apache |
| 43 | +Arrow Flight SQL adapter for PostgreSQL: |
| 44 | + |
| 45 | +- PostgreSQL |
| 46 | +- Apache Arrow Flight SQL C++ |
| 47 | +- Meson |
| 48 | +- CMake |
| 49 | +- Ninja |
| 50 | +- C++ compiler such as `g++` and `clang++` |
| 51 | + |
| 52 | +#### PostgreSQL |
| 53 | + |
| 54 | +You can find packages and source archive of PostgreSQL at |
| 55 | +https://www.postgresql.org/download/ . If you use packages, you need |
| 56 | +to install packages for development. For example, |
| 57 | +`postgresql-server-dev-XXX` is for deb packages and |
| 58 | +`postgresqlXXX-devel` is for RPM packages. |
| 59 | + |
| 60 | +The latest release is recommended. |
| 61 | + |
| 62 | +#### Apache Arrow Flight SQL C++ |
| 63 | + |
| 64 | +You can find packages and source archive of Apache Arrow C++ at |
| 65 | +https://arrow.apache.org/install/ . If you use packages, you need to |
| 66 | +install packages for development. For example, |
| 67 | +`libarrow-flight-sql-dev` is for deb packages and |
| 68 | +`arrow-flight-sql-devel` is for RPM packages. |
| 69 | + |
| 70 | +The latest release is recommended. |
| 71 | + |
| 72 | +#### Meson |
| 73 | + |
| 74 | +Meson is a build system that is also used by PostgreSQL. |
| 75 | + |
| 76 | +You can install Meson by system package managers such as `apt` and |
| 77 | +`brew`. |
| 78 | + |
| 79 | +For example, you can install Meson by `apt` on Debian GNU/Linux and |
| 80 | +Ubuntu: |
| 81 | + |
| 82 | +```bash |
| 83 | +sudo apt install meson |
| 84 | +``` |
| 85 | + |
| 86 | +For example, you can install Meson by `brew` on macOS: |
| 87 | + |
| 88 | +```bash |
| 89 | +brew install meson |
| 90 | +``` |
| 91 | + |
| 92 | +Or you can use `pip3` to install Meson: |
| 93 | + |
| 94 | +```bash |
| 95 | +pip3 install meson |
| 96 | +``` |
| 97 | + |
| 98 | +See also: https://mesonbuild.com/Getting-meson.html |
| 99 | + |
| 100 | +#### CMake |
| 101 | + |
| 102 | +CMake is also a build system. Meson uses CMake to find CMake |
| 103 | +packages. Apache Arrow Flight SQL adapter for PostgreSQL uses Apache |
| 104 | +Arrow Flight SQL C++ CMake package. So both of Meson and CMake are |
| 105 | +needed. |
| 106 | + |
| 107 | +If installing CMake bothers contributors, we can improving our build |
| 108 | +system to use CMake or pkg-config to find Apache Arrow Flight SQL |
| 109 | +C++. If you want the improvement, please report it to our issue |
| 110 | +tracker: https://github.com/apache/arrow-flight-sql-postgresql/issues |
| 111 | + |
| 112 | +You can install CMake by package managers such as `apt` and `brew`. |
| 113 | + |
| 114 | +For example, you can install CMake by `apt` on Debian GNU/Linux and |
| 115 | +Ubuntu: |
| 116 | + |
| 117 | +```bash |
| 118 | +sudo apt install cmake |
| 119 | +``` |
| 120 | + |
| 121 | +For example, you can install CMake by `brew` on macOS: |
| 122 | + |
| 123 | +```bash |
| 124 | +brew install cmake |
| 125 | +``` |
| 126 | + |
| 127 | +See also: https://cmake.org/install/ |
| 128 | + |
| 129 | +#### Ninja |
| 130 | + |
| 131 | +Ninja is also a build system but it differs from Meson and |
| 132 | +CMake. Meson and CMake only generate configuration files for Ninja and |
| 133 | +Ninja runs C++ compilers and so on based on the generated |
| 134 | +configuration files. |
| 135 | + |
| 136 | +You can install Ninja by package managers such as `apt` and `brew`. |
| 137 | + |
| 138 | +For example, you can install Ninja by `apt` on Debian GNU/Linux and |
| 139 | +Ubuntu: |
| 140 | + |
| 141 | +```bash |
| 142 | +sudo apt install ninja-build |
| 143 | +``` |
| 144 | + |
| 145 | +For example, you can install Ninja by `brew` on macOS: |
| 146 | + |
| 147 | +```bash |
| 148 | +brew install ninja |
| 149 | +``` |
| 150 | + |
| 151 | +See also: https://ninja-build.org/ |
| 152 | + |
| 153 | +### Build |
| 154 | + |
| 155 | +If you install PostgreSQL and Apache Arrow Flight SQL C++ to system |
| 156 | +directory such as `/usr`, you can use the following simple command |
| 157 | +lines: |
| 158 | + |
| 159 | +```bash |
| 160 | +meson setup build |
| 161 | +meson compile -C build |
| 162 | +meson install -C build |
| 163 | +``` |
| 164 | + |
| 165 | +If you install PostgreSQL to `/tmp/local`, you can use |
| 166 | +`-Dpostgresql_dir=/tmp/local` option: |
| 167 | + |
| 168 | +```bash |
| 169 | +meson setup -Dpostgresql_dir=/tmp/local build |
| 170 | +meson compile -C build |
| 171 | +meson install -C build |
| 172 | +``` |
| 173 | + |
| 174 | +If you specify `postgresql_dir`, it's recommended that you also |
| 175 | +specify `--prefix` with the same location. Apache Arrow Flight SQL |
| 176 | +adapter for PostgreSQL installs README and so on to |
| 177 | +`--prefix`: |
| 178 | + |
| 179 | +```bash |
| 180 | +meson setup -Dpostgresql_dir=/tmp/local --prefix=/tmp/local build |
| 181 | +meson compile -C build |
| 182 | +meson install -C build |
| 183 | +``` |
| 184 | + |
| 185 | +If you install Apache Arrow Flight SQL C++ to `/tmp/local`, you can |
| 186 | +use `--cmake-prefix-path`: |
| 187 | + |
| 188 | +```bash |
| 189 | +meson setup --cmake-prefix-path=/tmp/local build |
| 190 | +meson compile -C build |
| 191 | +meson install -C build |
| 192 | +``` |
| 193 | + |
| 194 | +I you want to build benchmark programs, you can use |
| 195 | +`-Dbenchmark=true`: |
| 196 | + |
| 197 | +```bash |
| 198 | +meson setup -Dbenchmark=true build |
| 199 | +meson compile -C build |
| 200 | +meson install -C build |
| 201 | +``` |
| 202 | + |
| 203 | +I you want to build example programs, you can use `-Dexmaple=true`: |
| 204 | + |
| 205 | +```bash |
| 206 | +meson setup -Dexample=true build |
| 207 | +meson compile -C build |
| 208 | +meson install -C build |
| 209 | +``` |
| 210 | + |
| 211 | +### Test |
| 212 | + |
| 213 | +You need Ruby and Red Arrow Flight SQL (red-arrow-flight-sql gem, |
| 214 | +Apache Arrow Flight SQL C++ bindings for Ruby) to run tests. |
| 215 | + |
| 216 | +You can install Ruby by package managers such as `apt` and `brew`. |
| 217 | + |
| 218 | +For example, you can install Ruby by `apt` on Debian GNU/Linux and |
| 219 | +Ubuntu: |
| 220 | + |
| 221 | +```bash |
| 222 | +sudo apt install ruby |
| 223 | +``` |
| 224 | + |
| 225 | +```bash |
| 226 | +brew install ruby |
| 227 | +``` |
| 228 | + |
| 229 | +You can install Red Arrow Flight SQL by Bundler that is bundled in |
| 230 | +Ruby: |
| 231 | + |
| 232 | +```bash |
| 233 | +bundle install |
| 234 | +``` |
| 235 | + |
| 236 | +You can run tests in the build directory. We can change the current |
| 237 | +directory before we run a Ruby script by `ruby`'s `-C` option: |
| 238 | + |
| 239 | +```bash |
| 240 | +bundle exec ruby -C build ../test/run.rb |
| 241 | +``` |
| 242 | + |
| 243 | +### Run |
| 244 | + |
| 245 | +You can use `dev/run-postgresql.sh` to run PostgreSQL with Apache |
| 246 | +Arrow Flight SQL adapter for PostgreSQL. You need to specify |
| 247 | +PostgreSQL data directory to use `dev/run-postgresql.sh`: |
| 248 | + |
| 249 | +```bash |
| 250 | +dev/run-postgresql.sh /tmp/afs |
| 251 | +``` |
| 252 | + |
| 253 | +You can connect to `grpc://127.0.0.1:15432`. |
| 254 | + |
| 255 | +If you build example programs, you can test the endpoint by the |
| 256 | +following command line: |
| 257 | + |
| 258 | +```bash |
| 259 | +PGDATABASE=postgres example/flight-sql/authenticate-password |
| 260 | +``` |
| 261 | + |
| 262 | +If you specify CA name, server name and client name, it also prepare |
| 263 | +TLS. |
| 264 | + |
| 265 | +For example, you can prepare `root.home`, `server.home` and |
| 266 | +`client.home` by adding the following entry to `/etc/hosts`: |
| 267 | + |
| 268 | +```text |
| 269 | +127.0.0.1 localhost root.home server.home client.home |
| 270 | +``` |
| 271 | + |
| 272 | +In this case, you can prepare TLS and run PostgreSQL by the following |
| 273 | +command line: |
| 274 | + |
| 275 | +```bash |
| 276 | +dev/run-postgresql.sh /tmp/afs root.home server.home client.home |
| 277 | +``` |
| 278 | + |
| 279 | +You can connect to `grpc+tls://server.home:15432`. You need to use |
| 280 | +`/tmp/afs/root.crt` for TLS root certificates. |
| 281 | + |
| 282 | +If you build example programs, you can test the endpoint by the |
| 283 | +following command line: |
| 284 | + |
| 285 | +```bash |
| 286 | +PGDATABASE=postgres \ |
| 287 | + PGHOST=server.home \ |
| 288 | + PGSSLMODE=require \ |
| 289 | + PGSSLROOTCERT=/tmp/afs/root.crt \ |
| 290 | + example/flight-sql/authenticate-password |
| 291 | +``` |
| 292 | + |
| 293 | +## Pull request |
| 294 | + |
| 295 | +Please open a new issue before you open a pull request. It's for the |
| 296 | +[Openness](http://theapacheway.com/open/) of this project. |
| 297 | + |
| 298 | +We don't have rules for pull request titles and commit messages |
| 299 | +yet. We may create rules later. Please see other merged pull requests |
| 300 | +for now. |
| 301 | + |
| 302 | +You can format codes automatically by |
| 303 | +[`pre-commit`](https://pre-commit.com/). |
| 304 | + |
| 305 | +You can install `pre-commit` by package managers such as `apt` and |
| 306 | +`brew`. |
| 307 | + |
| 308 | +For example, you can install `pre-commit` by `apt` on Debian GNU/Linux |
| 309 | +and Ubuntu: |
| 310 | + |
| 311 | +```bash |
| 312 | +sudo apt install pre-commit |
| 313 | +``` |
| 314 | + |
| 315 | +For example, you can install `pre-commit` by `brew` on macOS: |
| 316 | + |
| 317 | +```bash |
| 318 | +brew install pre-commit |
| 319 | +``` |
| 320 | + |
| 321 | +You can run `pre-commit` before you commit: |
| 322 | + |
| 323 | +```shell |
| 324 | +pre-commit run |
| 325 | +``` |
0 commit comments