View gist:63871738ff2df410b8d488d0235ec908
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client.create_stream_as(table_name='creditcardfraud_preprocessed_avro', | |
select_columns=['Time', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'V9', 'V10', 'V11', 'V12', 'V13', 'V14', 'V15', 'V16', 'V17', 'V18', 'V19', 'V20', 'V21', 'V22', 'V23', 'V24', 'V25', 'V26', 'V27', 'V28', 'Amount', 'Class'], | |
src_table='creditcardfraud_source', | |
conditions='Class IS NOT NULL', | |
kafka_topic='creditcardfraud_preprocessed_avro', | |
value_format='AVRO') |
View gist:375dc18cc721ef57a123df508ff64500
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE STREAM creditcardfraud_preprocessed_avro WITH (VALUE_FORMAT='AVRO', KAFKA_TOPIC='creditcardfraud_preprocessed_avro') AS SELECT Time, V1 , V2 , V3 , V4 , V5 , V6 , V7 , V8 , V9 , V10 , V11 , V12 , V13 , V14 , V15 , V16 , V17 , V18 , V19 , V20 , V21 , V22 , V23 , V24 , V25 , V26 , V27 , V28 , Amount , Class FROM creditcardfraud_source WHERE Class IS NOT NULL; |
View gist:fec77a553824119bfef29119c62826e8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ksql import KSQLAPI | |
client = KSQLAPI('http://localhost:8088') | |
client.create_stream(table_name='creditcardfraud_source', | |
columns_type=['Id bigint', 'Timestamp varchar', 'User varchar', 'Time int', 'V1 double', 'V2 double', 'V3 double', 'V4 double', 'V5 double', 'V6 double', 'V7 double', 'V8 double', 'V9 double', 'V10 double', 'V11 double', 'V12 double', 'V13 double', 'V14 double', 'V15 double', 'V16 double', 'V17 double', 'V18 double', 'V19 double', 'V20 double', 'V21 double', 'V22 double', 'V23 double', 'V24 double', 'V25 double', 'V26 double', 'V27 double', 'V28 double', 'Amount double', 'Class string'], | |
topic='creditcardfraud_source', | |
value_format='DELIMITED') |
View gist:5c4870e2af590465093fe89a9e0fa5b9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT Id, MASK_LEFT(User, 2) FROM creditcardfraud_source; |
View gist:fba5c442d047270ac63a8499066651d4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT Id, IFNULL(Class, -1) FROM creditcardfraud_source; |
View gist:cfcef6393cb2e2476dec25608b9de7a9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE STREAM creditcardfraud_per_user WITH (VALUE_FORMAT='AVRO', KAFKA_TOPIC='creditcardfraud_preprocessed_avro') AS SELECT Time, V1 , V2 , V3 , V4 , V5 , V6 , V7 , V8 , V9 , V10 , V11 , V12 , V13 , V14 , V15 , V16 , V17 , V18 , V19 , V20 , V21 , V22 , V23 , V24 , V25 , V26 , V27 , V28 , Amount , Class FROM creditcardfraud_enahnced c INNER JOIN USERS u on c.userid = u.userid WHERE V1 > 5 AND V2 IS NOT NULL AND u.CITY LIKE 'Premium%'; |
View testing-your-suppressions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
driver.pipeInput(recordFactory.create( | |
/* topic */ "input", | |
/* key */ "A", | |
/* value */ "v1", | |
/* timestamp */ 10L | |
)); | |
// Stream time is now 10L | |
driver.pipeInput(recordFactory.create("input", "A", "v2", 11L)); | |
// Stream time is now 11L |
View reconfiguring-buffer-size-at-runtime.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
builder | |
.table("users") | |
.suppress(Suppressed.untilTimeLimit( | |
BufferConfig.maxBytes(myConfig.getUsersBufferSize()) | |
)) | |
... |
View metrics-app-with-alerts.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
events | |
.groupByKey() | |
.windowedBy( | |
TimeWindows.of(Duration.ofMinutes(2).withGrace(Duration.ofMinutes(2)) | |
) | |
.count(Materialized.as("count-metric")) | |
.suppress(Suppressed.untilWindowClose(BufferConfig.unbounded())) | |
.filter( _ < 4 ) | |
.toStream() | |
.foreach( /* Send that email! */) |
View use-case-alerting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
events | |
.groupByKey() | |
.windowedBy(TimeWindows.of(Duration.ofMinutes(2))) | |
.count(Materialized.as("count-metric")) | |
.filter( _ < 4 ) | |
.toStream() | |
.foreach( /* Send that email! */) | |
// graph servlet queries "count-metric" |
OlderNewer