Skip to content

Commit

Permalink
Merge hive2 and hive3 support into one branch as Gradle subprojects (#…
Browse files Browse the repository at this point in the history
…108)



* Rename 'serde' subproject (from hive3 branch) to 'hive3'
* Rename 'serde' subproject (from hive2 branch)  to 'hive2'
* Update to Gradle 8.5
* Factor out duplicate code into a common subproject
* Refactor build scripts to eliminate duplicate logic
* Update copyright header

---------

Co-authored-by: Joshua Barr <[email protected]>
  • Loading branch information
popematt and jobarr-amzn committed Mar 1, 2024
1 parent 1956ea0 commit f8e9b0c
Show file tree
Hide file tree
Showing 168 changed files with 1,875 additions and 2,704 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
strategy:
matrix:
java: [8, 11]
subproject: [hive2, hive3]
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -21,4 +23,4 @@ jobs:
with:
java-version: ${{ matrix.java }}
- name: Build with Gradle
run: ./gradlew :serde:check
run: ./gradlew ${{ matrix.subproject }}:build
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ information to effectively respond to your bug report or contribution.

We welcome you to use the GitHub issue tracker to report bugs or suggest features.

When filing an issue, please check [existing open](https://github.com/amzn/amazon-ion-hive-serde/issues), or [recently closed](https://github.com/amzn/amazon-ion-hive-serde/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already
When filing an issue, please check [existing open](https://github.com/amazon-ion/ion-hive-serde/issues), or [recently closed](https://github.com/amazon-ion/ion-hive-serde/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already
reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:

* A reproducible test case or series of steps
Expand Down Expand Up @@ -41,7 +41,7 @@ GitHub provides additional document on [forking a repository](https://help.githu


## Finding contributions to work on
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/amzn/amazon-ion-hive-serde/labels/help%20wanted) issues is a great place to start.
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/amazon-ion/ion-hive-serde/labels/help%20wanted) issues is a great place to start.


## Code of Conduct
Expand All @@ -56,6 +56,6 @@ If you discover a potential security issue in this project we ask that you notif

## Licensing

See the [LICENSE](https://github.com/amzn/amazon-ion-hive-serde/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
See the [LICENSE](https://github.com/amazon-ion/ion-hive-serde/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.

We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@

### :warning: Please refer to `hive2` branch for ion-hive2-serde and `hive3` branch for ion-hive3-serde.

## Amazon Ion Hive Serde

A Apache Hive SerDe (short for serializer/deserializer) for the Ion file format.
An Apache Hive SerDe (short for serializer/deserializer) for the Ion file format, with support for Hive 2 and Hive 3.

[![Build Status](https://travis-ci.org/amzn/ion-hive-serde.svg?branch=master)](https://travis-ci.org/amzn/ion-hive-serde)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.amazon.ion/ion-hive-serde/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.amazon.ion/ion-hive-serde)
[![Javadoc](https://javadoc-badge.appspot.com/com.amazon.ion/ion-hive-serde.svg?label=javadoc)](http://www.javadoc.io/doc/com.amazon.ion/ion-hive-serde)
[![Build Status](https://github.com/amazon-ion/ion-hive-serde/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/amazon-ion/ion-hive-serde/actions?query=branch%3Amaster)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.amazon.ion/ion-hive2-serde/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.amazon.ion/ion-hive2-serde)
[![javadoc.io](https://javadoc.io/badge2/com.amazon.ion/ion-hive2-serde/javadoc.io.svg)](http://www.javadoc.io/doc/com.amazon.ion/ion-hive2-serde)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.amazon.ion/ion-hive3-serde/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.amazon.ion/ion-hive3-serde)
[![javadoc.io](https://javadoc.io/badge2/com.amazon.ion/ion-hive3-serde/javadoc.io.svg)](http://www.javadoc.io/doc/com.amazon.ion/ion-hive3-serde)

### Features
* Read data stored in Ion format both binary and text.
* Supports all Ion types including nested data structures, see [Type mapping documentation](docs/type-mapping.md)
for more information.
* Supports flattening of Ion documents through [path extraction](https://github.com/amzn/ion-java-path-extraction).
* Supports flattening of Ion documents through [path extraction](https://github.com/amazon-ion/ion-java-path-extraction).
* Supports importing shared symbol tables and custom symbol table catalogs.
* `IonInputFormat` and `IonOutputFormat` are able to handle both Ion binary and Ion text.
* Configurable through [SerDe properties](docs/serde-properties.md).

### Installation
Download the latest `ion-hive-serde-all-<version-number>.jar` from [https://github.com/amzn/ion-hive-serde/releases]
and place the JARs into `hive/lib` or use `ADD JAR` in Hive. That jar contains the SerDe and all its dependencies.
Download the latest `ion-hive(2|3)-serde-all-<version-number>.jar` from [https://github.com/amazon-ion/ion-hive-serde/releases]. (Some releases may have a slightly different jar name, such as `ion-hive(2|3)-serde-<version-number>-all.jar`.)

To build it locally run :`./gradlew :serde:singleJar`
To build it locally run :`./gradlew shadowJar`

### Building
Project is separated into two modules:
1. `serde`: with the SerDe code and unit tests.
Project is separated into modules:
1. `hive2`: with the SerDe code and unit tests for Hive 2.
1. `hive3`: with the SerDe code and unit tests for Hive 3.
1. `integration-tests`: integration tests using a dockerized hive installation.

To build only the SerDe code:
```
./gradlew :serde:build
./gradlew :hive2:build :hive3:build
```

To build the SerDe including integration tests:
Expand Down
84 changes: 4 additions & 80 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,83 +1,7 @@
/*
* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file 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.
*/

// sets up kotlin plugin
buildscript {
ext.kotlin_version = '[1.2.0,1.4.10)'
ext.ionjava_version = '[1.4.0,2.0.0)'
ext.pathextraction_version = '[1.2.0,2.0.0)'
ext.hive_version = '[2.3.0,2.4.0)'
ext.hadoop_version = '[2.7.0,2.8.0)'

repositories {
mavenCentral()
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

allprojects {
repositories {
mavenCentral()
}

apply plugin: "kotlin"


configurations {
// to make compileOnly available to testing scope
testCompile.extendsFrom(compileOnly)
}

dependencies {
// using kotlin to make tests less verbose
testCompile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"

testCompile "junit:junit:[4.0.0,5.0.0)"
testCompile "pl.pragmatists:JUnitParams:[1.1.0,1.2.0)"
}

apply plugin: 'checkstyle'
checkstyle {
toolVersion = "8.18"
ignoreFailures = false
maxWarnings = 0
maxErrors = 0
configDir = file("$rootProject.projectDir/config/checkstyle")
}
tasks.withType(Checkstyle) {
reports {
xml.enabled = false
html.enabled = true
}
}
}

// clean all subprojects
task cleanAll {
subprojects.each {
it.afterEvaluate {
def cleanTask = it.tasks.findByName('clean')
if (cleanTask) {
dependsOn(cleanTask)
}
}
}

dependsOn(clean)
group = "com.amazon.ion"
version = "1.3.0-SNAPSHOT"
}
16 changes: 16 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

repositories {
gradlePluginPortal()
mavenCentral()
}

plugins {
`kotlin-dsl`
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22")
implementation("com.github.johnrengelman:shadow:8.1.1")
}
57 changes: 57 additions & 0 deletions buildSrc/src/main/kotlin/ion-hive-serde.conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import org.jetbrains.kotlin.gradle.plugin.extraProperties
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URI

repositories {
mavenCentral()
}

plugins {
kotlin("jvm")
id("checkstyle")
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
}

checkstyle {
toolVersion = "8.18"
// TODO: Fix checkstyle failures
isIgnoreFailures = false
maxWarnings = 0
maxErrors = 0
}

tasks {

withType<JavaCompile>().all {
// The release option is not available for the Java 8 compiler, but that's okay because we're targeting 8.
if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
options.release.set(8)
}
}

withType<KotlinCompile>().all {
kotlinOptions {
jvmTarget = "1.8"
}
}

withType<Test>().all {
useJUnitPlatform()
doLast {
logger.quiet("Test report written to: file://${reports.html.entryPoint}")
}
}

withType<Checkstyle>().all {
reports {
xml.required.set(false)
html.required.set(true)
}
}
}
57 changes: 57 additions & 0 deletions buildSrc/src/main/kotlin/ion-hive-serde.dependencies.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import org.jetbrains.kotlin.gradle.plugin.extraProperties
import java.net.URI

/*
* This manages all of the dependencies by creating configurations for different groups of dependencies that belong
* together. These groups can be added to the standard configurations (e.g. `testImplementation`) by using the
* `extendFrom(...)` method in the `configurations` block.
*/

// Dependencies that get bundled into the fat Jar
val bundled = configurations.create("bundled")
// Dependencies provided by Hive
val hive2Runtime = configurations.create("hive2Runtime")
val hive3Runtime = configurations.create("hive3Runtime")
// Test dependencies
val testFramework = configurations.create("testFramework")

object Versions {
val hive2_version = "[2.3.0,2.4.0)"
val hive3_version = "[3.1.2,3.1.17)"
val kotlin_version = "1.9.22"
val ionjava_version = "[1.4.0,2.0.0)"
val pathextraction_version = "[1.2.0,2.0.0)"
val hadoop_version = "[2.7.0,2.8.0)"
}

dependencies {
with(Versions) {
bundled("com.amazon.ion:ion-java:${ionjava_version}")
bundled("com.amazon.ion:ion-java-path-extraction:${pathextraction_version}") {
// ion-java-path-extraction uses Kotlin only for testing
exclude(group = "org.jetbrains.kotlin")
}

// Provided by the Hive installation
hive2Runtime("org.apache.hive:hive-serde:${hive2_version}")
hive2Runtime("org.apache.hive:hive-exec:${hive2_version}") { isTransitive = false }
hive2Runtime("org.apache.hadoop:hadoop-common:${hadoop_version}")
hive2Runtime("org.apache.hadoop:hadoop-main:${hadoop_version}")
hive2Runtime("org.apache.hadoop:hadoop-mapreduce-client-core:${hadoop_version}")

// Provided by the Hive installation
hive3Runtime("org.apache.hive:hive-serde:${hive3_version}")
hive3Runtime("org.apache.hive:hive-exec:${hive3_version}") { isTransitive = false }
hive3Runtime("org.apache.hadoop:hadoop-common:${hadoop_version}")
hive3Runtime("org.apache.hadoop:hadoop-main:${hadoop_version}")
hive3Runtime("org.apache.hadoop:hadoop-mapreduce-client-core:${hadoop_version}")

testFramework("pl.pragmatists:JUnitParams:[1.1.0,1.2.0)")
testFramework("org.junit.jupiter:junit-jupiter:5.7.1")
testFramework("org.junit.vintage:junit-vintage-engine")
testFramework("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
}
}
Loading

0 comments on commit f8e9b0c

Please sign in to comment.