Skip to content

Commit fc4d6e8

Browse files
Add implementation for XTable REST Service (#704)
* Add module for xtable rest service * Use builder pattern, spotless fix * Add unit test for conversion resource * Refactor code for easier testing, add unit test for service * Fix other failing modules tests by moving quarkus bom into xtable service * Add metadata helper utils, test other formats * Address Vinish intial set of comments * add unit test for util * minor fix for other unit test * spotless * fix dependency conflict to make unit tests run in ci * minor mvn fix * Address Vinish remaining comments * Address Vinish comments * Make sourceProviders private final --------- Co-authored-by: Vinish Reddy <[email protected]>
1 parent 81e8364 commit fc4d6e8

15 files changed

+1139
-2
lines changed

pom.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
<module>xtable-utilities</module>
5454
<module>xtable-aws</module>
5555
<module>xtable-hive-metastore</module>
56+
<module>xtable-service</module>
5657
</modules>
5758

5859
<properties>
@@ -63,6 +64,7 @@
6364
<avro.version>1.11.4</avro.version>
6465
<log4j.version>2.22.0</log4j.version>
6566
<junit.version>5.11.4</junit.version>
67+
<junit.platform.runner.version>1.11.4</junit.platform.runner.version>
6668
<lombok.version>1.18.36</lombok.version>
6769
<lombok-maven-plugin.version>1.18.20.0</lombok-maven-plugin.version>
6870
<hadoop.version>3.4.1</hadoop.version>
@@ -97,6 +99,11 @@
9799
<apache-jar-resource-bundle.version>1.7</apache-jar-resource-bundle.version>
98100
<apache-incubator-disclaimer-resource-bundle.version>1.7</apache-incubator-disclaimer-resource-bundle.version>
99101
<scala-collection-compat.version>2.12.0</scala-collection-compat.version>
102+
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
103+
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
104+
<quarkus.platform.version>3.2.12.Final</quarkus.platform.version> <!-- compatible with Java 11 -->
105+
<antlr4.version>4.9.3</antlr4.version>
106+
<jol.core.version>0.16</jol.core.version>
100107

101108
<!-- Test properties -->
102109
<skipTests>false</skipTests>
@@ -457,7 +464,7 @@
457464
<dependency>
458465
<groupId>org.openjdk.jol</groupId>
459466
<artifactId>jol-core</artifactId>
460-
<version>0.16</version>
467+
<version>${jol.core.version}</version>
461468
<scope>test</scope>
462469
</dependency>
463470

@@ -483,7 +490,7 @@
483490
<dependency>
484491
<groupId>org.junit.platform</groupId>
485492
<artifactId>junit-platform-runner</artifactId>
486-
<version>1.11.4</version>
493+
<version>${junit.platform.runner.version}</version>
487494
<scope>test</scope>
488495
</dependency>
489496
<dependency>

xtable-service/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
# XTable REST Service
21+
22+
The `rest-service-open-api.yaml` defines the api contract for running table format conversion using XTable's REST service.
23+
See XTable's `spec` module for more details: https://github.com/apache/incubator-xtable/tree/main/spec
24+
25+
## How to run the service locally
26+
27+
#### Before running the service, ensure that you have the required credentials set in your enviroment needed to read and write to cloud storage.
28+
29+
To run the service locally, first ensure you have built the project with
30+
```sh
31+
mvn clean install -DskipTests
32+
```
33+
34+
35+
Then you can run start the quarkus service using the following command:
36+
```sh
37+
mvn quarkus:dev -pl xtable-service
38+
```
39+
This will start the service on `http://localhost:8080`.
40+
41+
Note quarkus will automatically reload the service when you make changes to the code.
42+
43+
## Testing with Postman
44+
45+
If you would like to test the service with an api client, you can download Postman https://www.postman.com/downloads/
46+
47+
Ensure that when you are testing that you have set the service URL, headers, and request body correctly.
48+
See the screenshots below for an example.
49+
50+
![Screenshot 2025-05-01 at 9.04.59 AM.png](examples/Screenshot%202025-05-01%20at%209.04.59%E2%80%AFAM.png)
51+
52+
![Screenshot 2025-05-01 at 9.05.10 AM.png](examples/Screenshot%202025-05-01%20at%209.05.10%E2%80%AFAM.png)
271 KB
Loading
282 KB
Loading

xtable-service/pom.xml

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to You under the Apache License, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ 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, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
-->
18+
<project xmlns="http://maven.apache.org/POM/4.0.0"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
<parent>
23+
<groupId>org.apache.xtable</groupId>
24+
<artifactId>xtable</artifactId>
25+
<version>0.2.0-SNAPSHOT</version>
26+
</parent>
27+
28+
<artifactId>xtable-service</artifactId>
29+
30+
<dependencyManagement>
31+
<dependencies>
32+
<dependency>
33+
<groupId>${quarkus.platform.group-id}</groupId>
34+
<artifactId>${quarkus.platform.artifact-id}</artifactId>
35+
<version>${quarkus.platform.version}</version>
36+
<type>pom</type>
37+
<scope>import</scope>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.antlr</groupId>
41+
<artifactId>antlr4-runtime</artifactId>
42+
<version>${antlr4.version}</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.scala-lang</groupId>
46+
<artifactId>scala-reflect</artifactId>
47+
<version>${scala.version}</version>
48+
</dependency>
49+
</dependencies>
50+
</dependencyManagement>
51+
52+
<dependencies>
53+
<dependency>
54+
<groupId>org.apache.xtable</groupId>
55+
<artifactId>xtable-core_${scala.binary.version}</artifactId>
56+
<version>${project.version}</version>
57+
</dependency>
58+
59+
<dependency>
60+
<groupId>org.apache.hadoop</groupId>
61+
<artifactId>hadoop-aws</artifactId>
62+
</dependency>
63+
64+
<!-- Spark -->
65+
<dependency>
66+
<groupId>org.apache.spark</groupId>
67+
<artifactId>spark-core_${scala.binary.version}</artifactId>
68+
<scope>provided</scope>
69+
</dependency>
70+
<dependency>
71+
<groupId>org.apache.spark</groupId>
72+
<artifactId>spark-sql_${scala.binary.version}</artifactId>
73+
<scope>provided</scope>
74+
</dependency>
75+
76+
<dependency>
77+
<groupId>com.fasterxml.jackson.core</groupId>
78+
<artifactId>jackson-annotations</artifactId>
79+
<version>${jackson.version}</version>
80+
</dependency>
81+
<dependency>
82+
<groupId>com.fasterxml.jackson.core</groupId>
83+
<artifactId>jackson-databind</artifactId>
84+
<version>${jackson.version}</version>
85+
</dependency>
86+
87+
<dependency>
88+
<groupId>io.quarkus</groupId>
89+
<artifactId>quarkus-arc</artifactId>
90+
</dependency>
91+
<dependency>
92+
<groupId>io.quarkus</groupId>
93+
<artifactId>quarkus-resteasy-reactive</artifactId>
94+
</dependency>
95+
<dependency>
96+
<groupId>io.quarkus</groupId>
97+
<artifactId>quarkus-resteasy-reactive-jackson</artifactId>
98+
</dependency>
99+
<dependency>
100+
<groupId>io.rest-assured</groupId>
101+
<artifactId>rest-assured</artifactId>
102+
<scope>test</scope>
103+
</dependency>
104+
105+
<!-- Junit -->
106+
<dependency>
107+
<groupId>org.junit.jupiter</groupId>
108+
<artifactId>junit-jupiter-api</artifactId>
109+
<scope>test</scope>
110+
</dependency>
111+
<dependency>
112+
<groupId>org.junit.jupiter</groupId>
113+
<artifactId>junit-jupiter-params</artifactId>
114+
<scope>test</scope>
115+
</dependency>
116+
<dependency>
117+
<groupId>org.junit.jupiter</groupId>
118+
<artifactId>junit-jupiter-engine</artifactId>
119+
<scope>test</scope>
120+
</dependency>
121+
<dependency>
122+
<groupId>org.junit.platform</groupId>
123+
<artifactId>junit-platform-commons</artifactId>
124+
<version>${junit.platform.runner.version}</version>
125+
<scope>test</scope>
126+
</dependency>
127+
<dependency>
128+
<groupId>org.junit.platform</groupId>
129+
<artifactId>junit-platform-engine</artifactId>
130+
<version>${junit.platform.runner.version}</version>
131+
<scope>test</scope>
132+
</dependency>
133+
134+
<!-- Mockito -->
135+
<dependency>
136+
<groupId>org.mockito</groupId>
137+
<artifactId>mockito-core</artifactId>
138+
<scope>test</scope>
139+
</dependency>
140+
<dependency>
141+
<groupId>org.mockito</groupId>
142+
<artifactId>mockito-junit-jupiter</artifactId>
143+
<scope>test</scope>
144+
</dependency>
145+
<dependency>
146+
<groupId>org.openjdk.jol</groupId>
147+
<artifactId>jol-core</artifactId>
148+
<version>${jol.core.version}</version>
149+
<scope>runtime</scope>
150+
</dependency>
151+
152+
</dependencies>
153+
<build>
154+
<plugins>
155+
<plugin>
156+
<groupId>${quarkus.platform.group-id}</groupId>
157+
<artifactId>quarkus-maven-plugin</artifactId>
158+
<version>${quarkus.platform.version}</version>
159+
<extensions>true</extensions>
160+
<executions>
161+
<execution>
162+
<goals>
163+
<goal>build</goal>
164+
<goal>generate-code</goal>
165+
<goal>generate-code-tests</goal>
166+
</goals>
167+
</execution>
168+
</executions>
169+
</plugin>
170+
</plugins>
171+
</build>
172+
173+
174+
</project>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.xtable.service;
20+
21+
import org.apache.xtable.service.models.ConvertTableRequest;
22+
import org.apache.xtable.service.models.ConvertTableResponse;
23+
24+
import io.smallrye.common.annotation.Blocking;
25+
import jakarta.inject.Inject;
26+
import jakarta.ws.rs.Consumes;
27+
import jakarta.ws.rs.POST;
28+
import jakarta.ws.rs.Path;
29+
import jakarta.ws.rs.Produces;
30+
import jakarta.ws.rs.core.MediaType;
31+
32+
@Path("/v1/conversion")
33+
@Produces(MediaType.APPLICATION_JSON)
34+
@Consumes(MediaType.APPLICATION_JSON)
35+
public class ConversionResource {
36+
37+
@Inject ConversionService conversionService;
38+
39+
@POST
40+
@Path("/table")
41+
@Blocking
42+
public ConvertTableResponse convertTable(ConvertTableRequest convertTableRequest) {
43+
return conversionService.convertTable(convertTableRequest);
44+
}
45+
}

0 commit comments

Comments
 (0)