[FLaNK] Smart Weather Applications with Flink SQL
Published: 2020-11-09 18:39:28

---
title: [FLaNK] Smart Weather Applications with Flink SQL
published: true
date: 2020-11-09 18:36:00 UTC
tags: 
canonical_url: 
---

#  [FLaNK] Smart Weather Applications with Flink SQL 

Sometimes you want to acquire, route, transform, live query and analyze all the weather data in the United States while those reports happen.   With FLaNK, it's a trivial process to do.

[![](https://1.bp.blogspot.com/-BSsZ5MX17Wc/X5r3UGCaFwI/AAAAAAAAbzE/3dzzd9SHkYALccsLt9Lj4lMktPjixEpsgCLcBGAsYHQ/w569-h477/drilldownmap.png)](https://1.bp.blogspot.com/-BSsZ5MX17Wc/X5r3UGCaFwI/AAAAAAAAbzE/3dzzd9SHkYALccsLt9Lj4lMktPjixEpsgCLcBGAsYHQ/s1402/drilldownmap.png)
  

[![](https://1.bp.blogspot.com/-oO7lZYdxF4o/X5r3UJ8IWuI/AAAAAAAAbzM/3qmM09yZDHkb8maRh854Zu8A2W0O-DBsQCLcBGAsYHQ/w533-h271/flinkglobal1.png)](https://1.bp.blogspot.com/-oO7lZYdxF4o/X5r3UJ8IWuI/AAAAAAAAbzM/3qmM09yZDHkb8maRh854Zu8A2W0O-DBsQCLcBGAsYHQ/s2048/flinkglobal1.png)
  

[![](https://1.bp.blogspot.com/-xIYwvztfuSo/X5r3UBA5T8I/AAAAAAAAbzI/_DNMoAai4U0PGE9zeFGIaUka74YEPnyagCLcBGAsYHQ/w662-h292/flinkInsert.png)](https://1.bp.blogspot.com/-xIYwvztfuSo/X5r3UBA5T8I/AAAAAAAAbzI/_DNMoAai4U0PGE9zeFGIaUka74YEPnyagCLcBGAsYHQ/s2498/flinkInsert.png)

  

**From Kafka to Kudu for Any Schema of Any Type of Data, No Code, Two Steps**
  

[![](https://1.bp.blogspot.com/-tS2gSJc_0hs/X5r3U2MutJI/AAAAAAAAbzQ/oJWscCbG9ps2GIyFwJBa6Q8JrZeqhfGWgCLcBGAsYHQ/w640-h258/kafkatokudu.png)](https://1.bp.blogspot.com/-tS2gSJc_0hs/X5r3U2MutJI/AAAAAAAAbzQ/oJWscCbG9ps2GIyFwJBa6Q8JrZeqhfGWgCLcBGAsYHQ/s2464/kafkatokudu.png)

  

**The Schema Registry has full Swagger-ized Runnable REST API Documentation.   Integrate, DevOps and Migration in a simple [script](https://github.com/tspannhw/ApacheConAtHome2020/blob/main/scripts/setup.sh). **  

[![](https://1.bp.blogspot.com/-lJDUU-0TyUc/X5r3VCBFr0I/AAAAAAAAbzU/ow4f_k_4JvMbgKSLKIIiH1tZHq1_RGfWwCLcBGAsYHQ/w640-h442/swaggerschemareg.png)](https://1.bp.blogspot.com/-lJDUU-0TyUc/X5r3VCBFr0I/AAAAAAAAbzU/ow4f_k_4JvMbgKSLKIIiH1tZHq1_RGfWwCLcBGAsYHQ/s1756/swaggerschemareg.png)

  

  

**Here's your schemas, upload, edit and compare.**

  

[![](https://1.bp.blogspot.com/-043u_G8aD2Y/X5r3YzZw8AI/AAAAAAAAbzw/d7RD6MR8NjcGDjvJYpmahJj4o9pUZuGBQCLcBGAsYHQ/w640-h504/weatherschemas.png)](https://1.bp.blogspot.com/-043u_G8aD2Y/X5r3YzZw8AI/AAAAAAAAbzw/d7RD6MR8NjcGDjvJYpmahJj4o9pUZuGBQCLcBGAsYHQ/s1464/weatherschemas.png)

  

**Validating Data Against a Schema With Your Approved Level of Tolerance.   You want extra fields allowed, you got it.**

  

[![nifi](https://1.bp.blogspot.com/-5ffmuX1qAmU/X5r3VpGiHTI/AAAAAAAAbzY/TMW3-tlLufEMC6MUJBirqglwDPrqT54pACLcBGAsYHQ/w634-h640/validateAndProduce.png)](https://1.bp.blogspot.com/-5ffmuX1qAmU/X5r3VpGiHTI/AAAAAAAAbzY/TMW3-tlLufEMC6MUJBirqglwDPrqT54pACLcBGAsYHQ/s1035/validateAndProduce.png)

  

**Feed that data to beautiful visual applications running in Cloudera Machine Learning.**

  

[![](https://1.bp.blogspot.com/-QLG1bgb3oBk/X5r3XZsjKjI/AAAAAAAAbzk/FFJdsRJZbsMoP1P93GN5gVUIYziN3fZhQCLcBGAsYHQ/w640-h536/weatherapp2.png)](https://1.bp.blogspot.com/-QLG1bgb3oBk/X5r3XZsjKjI/AAAAAAAAbzk/FFJdsRJZbsMoP1P93GN5gVUIYziN3fZhQCLcBGAsYHQ/s1407/weatherapp2.png)
**You like drill down maps, you got them.**

  

[![](https://1.bp.blogspot.com/-6A99qULoB3U/X5r3WyjtQ2I/AAAAAAAAbzg/e9JJT8bhOggrRqSu_Qee_CymrWC9P1bhgCLcBGAsYHQ/w640-h534/weatherapp.png)](https://1.bp.blogspot.com/-6A99qULoB3U/X5r3WyjtQ2I/AAAAAAAAbzg/e9JJT8bhOggrRqSu_Qee_CymrWC9P1bhgCLcBGAsYHQ/s1414/weatherapp.png)

  

**Query your data fast with Apache Hue against Apache Kudu tables through Apache Impala.**

  

[![](https://1.bp.blogspot.com/-BjPazqFv26Y/X5r3XyGWkHI/AAAAAAAAbzo/uL8mYHjuiKk-MNd-p73Ly-WDLAOek93kQCLcBGAsYHQ/w640-h468/weatherhue.png)](https://1.bp.blogspot.com/-BjPazqFv26Y/X5r3XyGWkHI/AAAAAAAAbzo/uL8mYHjuiKk-MNd-p73Ly-WDLAOek93kQCLcBGAsYHQ/s1536/weatherhue.png)

  

  

**Let's ingest all the US weather stations even though they are a zipped directory of a ton of XML files.**

  

[![](https://1.bp.blogspot.com/-yWoOZkKZWCw/X5r3YQS3UAI/AAAAAAAAbzs/f16NAAkUbwQP-KIst28Tpj5J6KbOZcj6ACLcBGAsYHQ/w472-h640/weatheringest.png)](https://1.bp.blogspot.com/-yWoOZkKZWCw/X5r3YQS3UAI/AAAAAAAAbzs/f16NAAkUbwQP-KIst28Tpj5J6KbOZcj6ACLcBGAsYHQ/s1028/weatheringest.png)

  

  

**Weather Ingest is Easy Automagically**

  

[![](https://1.bp.blogspot.com/-pkQNzHQlIoI/X5r3WRYZoJI/AAAAAAAAbzc/naM8U_dwxicjFvAtBRsMmkhQXgqIPozTwCLcBGAsYHQ/w640-h392/weatherProcessing.png)](https://1.bp.blogspot.com/-pkQNzHQlIoI/X5r3WRYZoJI/AAAAAAAAbzc/naM8U_dwxicjFvAtBRsMmkhQXgqIPozTwCLcBGAsYHQ/s1085/weatherProcessing.png)
  

**View All Your Topic Data Enabled by Schema Registry Even in Avro Format**
  

[![](https://1.bp.blogspot.com/-TRsVRCQiCC8/X5r3ZLq6CyI/AAAAAAAAbz0/rU3HroK44mERF3fyMoKpVdwCvlkTyDPdQCLcBGAsYHQ/w640-h368/weathersmm.png)](https://1.bp.blogspot.com/-TRsVRCQiCC8/X5r3ZLq6CyI/AAAAAAAAbz0/rU3HroK44mERF3fyMoKpVdwCvlkTyDPdQCLcBGAsYHQ/s1838/weathersmm.png)
  

### Reference:

[https://www.datainmotion.dev/2020/07/ingesting-all-weather-data-with-apache.html](https://dev.to/tspannhw/ingesting-all-the-weather-data-with-apache-nifi-2ho4)

### Source:

**Build**

[https://github.com/tspannhw/ApacheConAtHome2020/blob/main/scripts/setup.sh](https://github.com/tspannhw/ApacheConAtHome2020/blob/main/scripts/setup.sh)

**Query**

[https://github.com/tspannhw/ApacheConAtHome2020/blob/main/scripts/flink.sh](https://github.com/tspannhw/ApacheConAtHome2020/blob/main/scripts/flink.sh)

**SQL**

| INSERT INTO weathernj |
| | SELECT `location`, station\_id,latitude,longitude,observation\_time,weather, |
| | temperature\_string, temp\_f,temp\_c,relative\_humidity,wind\_string,wind\_dir,wind\_degrees,wind\_mph, |
| | wind\_kt, pressure\_in,dewpoint\_string,dewpoint\_f,dewpoint\_c |
| | FROM weather |
| | WHERE |
| | `location` is not null and `location` <> 'null' and trim(`location`) <> '' and `location` like '%NJ'; |

**Kafka Insert**

[https://github.com/tspannhw/ApacheConAtHome2020/blob/main/flinksql/weathernj.sql](https://github.com/tspannhw/ApacheConAtHome2020/blob/main/flinksql/weathernj.sql)

**Schemas**

[https://github.com/tspannhw/ApacheConAtHome2020/blob/main/schemas/weathernj.avsc](https://github.com/tspannhw/ApacheConAtHome2020/blob/main/schemas/weathernj.avsc)

[https://github.com/tspannhw/ApacheConAtHome2020/blob/main/schemas/weather.avsc](https://github.com/tspannhw/ApacheConAtHome2020/blob/main/schemas/weather.avsc)

**Example Slack Output**

[12:56](https://nifi-se.slack.com/archives/C019QMV81RT/p1603990564029300)

=========================================================  
[http://forecast.weather.gov/images/wtf/small/ovc.png](http://forecast.weather.gov/images/wtf/small/ovc.png)Location Cincinnati/Northern Kentucky International Airport, KY Station KCVG  
Temperature: 49.0 F (9.4 C)  
Humdity: 83  
Wind East at 3.5 MPH (3 KT)  
Overcast  
Dewpoint 44.1 F (6.7 C)Observed at Tue, 27 Oct 2020 11:52:00 -0400---- tracking info ---- <wbr style="box-sizing: inherit;"></wbr>  <wbr style="box-sizing: inherit;"></wbr>  <wbr style="box-sizing: inherit;"></wbr>  <wbr style="box-sizing: inherit;"></wbr>  <wbr style="box-sizing: inherit;"></wbr> UUID: 2cb6bd67-148c-497d-badf-dfffb4906b89  
 <wbr style="box-sizing: inherit;"></wbr> Kafka offset: 0  
Kafka Timestamp: 1603818351260  
=========================================================