Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 21 additions & 26 deletions guides/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ This tutorial will show users how to run the WordCount example locally with Waya

# Clone repository
```shell
git clone https://github.com/apache/incubator-wayang.git
git clone https://github.com/apache/wayang.git
```

# Create binaries
Running following commands to build Wayang and generate the tar.gz
```shell
cd incubator-wayang
cd wayang
./mvnw clean package -pl :wayang-assembly -Pdistribution
```
Then you can find the `wayang-assembly-1.1.1-SNAPSHOT-dist.tar.gz` under `wayang-assembly/target` directory.
Then you can find the `wayang-assembly-1.1.2-SNAPSHOT-dist.tar.gz` under `wayang-assembly/target` directory.


# Prepare the environment
## Wayang
```shell
tar -xvf wayang-assembly-1.1.1-SNAPSHOT-dist.tar.gz
cd wayang-1.1.1-SNAPSHOT
tar -xvf wayang-assembly-1.1.2-SNAPSHOT-dist.tar.gz
cd wayang-1.1.2-SNAPSHOT
```

In linux
Expand All @@ -60,11 +60,11 @@ source ~/.zshrc
To execute the WordCount example with Apache Wayang, you need to execute your program with the 'wayang-submit' command:

```shell
cd wayang-1.1.1-SNAPSHOT
cd wayang-1.1.2-SNAPSHOT
./bin/wayang-submit org.apache.wayang.apps.wordcount.Main java file://$(pwd)/README.md
```
## If you're using Java 17, add the following JVM flags:
Update your `wayang-submit` (wayang-assembly/target/wayang-1.0.1-SNAPSHOT/bin/wayang-submit) script (or command) with:
## If you're using Java 17, add the following JVM flags:
Update your `wayang-submit` (`wayang-assembly/target/wayang-1.1.2-SNAPSHOT/bin/wayang-submit`) script (or command) with:

```shell
eval "$RUNNER \
Expand All @@ -83,46 +83,40 @@ eval "$RUNNER \
Then you should be able to see outputs like this:

![img.png](../images/wordcount_result.png)

## Running SQL Queries in Wayang

Wayang provides support for executing SQL queries using its SQL API.

### Example

```sql
SELECT * FROM my_table;
### Steps to execute SQL queries

1. Configure the Wayang Calcite model using the property:
`wayang.calcite.model`

2. Create a `SqlContext` instance:

```java
SqlContext context = new SqlContext(configuration);
Example configuration:
1. Configure the Wayang Calcite model using the property `wayang.calcite.model`:

```java
Configuration configuration = new Configuration();
configuration.setProperty(
"wayang.calcite.model",
"{ \"version\": \"1.0\", \"defaultSchema\": \"MY_SCHEMA\", \"schemas\": [] }"
);
```

---

## πŸ‘‰ Step 2 β€” Improve SQL execution step
2. Create a `SqlContext` instance:

Below this:
```java
SqlContext context = new SqlContext(configuration);
```

```md
3. Execute your SQL query:

```java
Collection<Record> result = context.executeSql("SELECT * FROM my_table");

for (Record record : result) {
System.out.println(record);
}
### Example: Running a simple SQL query
```

### Example: Running a SQL Query

Wayang allows executing SQL queries using the `SqlContext` API.

Expand Down Expand Up @@ -151,3 +145,4 @@ public class Example {
}
}
}
```