diff --git a/guides/tutorial.md b/guides/tutorial.md index a9b8a92da..52eaeb6c4 100644 --- a/guides/tutorial.md +++ b/guides/tutorial.md @@ -83,3 +83,71 @@ 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: + +```java +configuration.setProperty( + "wayang.calcite.model", + "{ \"version\": \"1.0\", \"defaultSchema\": \"MY_SCHEMA\", \"schemas\": [] }" +); + +--- + +## 👉 Step 2 — Improve SQL execution step + +Below this: + +```md +3. Execute your SQL query: +```java +Collection result = context.executeSql("SELECT * FROM my_table"); + +for (Record record : result) { + System.out.println(record); +} +### Example: Running a simple SQL query + +Wayang allows executing SQL queries using the `SqlContext` API. + +```java +import org.apache.wayang.api.sql.context.SqlContext; +import org.apache.wayang.core.api.Configuration; +import org.apache.wayang.basic.data.Record; + +import java.util.Collection; + +public class Example { + public static void main(String[] args) throws Exception { + Configuration configuration = new Configuration(); + + configuration.setProperty( + "wayang.calcite.model", + "{ \"version\": \"1.0\", \"defaultSchema\": \"MY_SCHEMA\", \"schemas\": [] }" + ); + + SqlContext context = new SqlContext(configuration); + + Collection result = context.executeSql("SELECT * FROM my_table"); + + for (Record record : result) { + System.out.println(record); + } + } +} diff --git a/guides/windows-setup.md b/guides/windows-setup.md index fcdb084d0..1ac79310f 100644 --- a/guides/windows-setup.md +++ b/guides/windows-setup.md @@ -9,7 +9,7 @@ http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, +nano windows-setup.mdnano windows-setup.md Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the @@ -132,3 +132,25 @@ Run terminal as Administrator. You are now ready to run Apache Wayang on Windows. +### Hadoop prerequisite issue on Windows + +While building Wayang on Windows, Maven may fail due to a missing Hadoop dependency. + +Error example: +Execution prerequisite-check failed: could not access constructor... + +This happens because Wayang expects the file: + +C:\hadoop\bin\winutils.exe + +Fix: + +1. Create folder C:\hadoop +2. Inside create folder bin +3. Inside bin create an empty file called winutils.exe + +After this run: + +mvn clean install -DskipTests + +The build should work correctly.