@@ -17,41 +17,19 @@ let metadata;
17
17
console.log('this is the result', result);
18
18
}
19
19
20
- pullTest();
20
+ pullTest(); */
21
21
22
22
//---------------------Test Push Queries-------------------
23
- const pushTest = async () => {
24
- // metadata = await client.push('SELECT * FROM riderlocations EMIT CHANGES LIMIT 1;', (row) => console.log(row));
25
- // console.log('this is the metadata returned ', metadata);
26
- let pushActive = false;
27
- await client.createStream('TESTJESTSTREAM', ['age INTEGER'], 'testJestTopic', 'json', 1);
28
- // await client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES LIMIT 1;', (data) => {
29
- // console.log(data);
30
- // console.log('HERE IS DATA ', JSON.parse(data).queryId)
31
- // if(JSON.parse(data).queryId){
32
- // pushActive = true;
33
- // }
34
- // client.ksql(`TERMINATE ${JSON.parse(data).queryId};`)
35
- // client.ksql('DROP STREAM IF EXISTS TESTJESTSTREAM DELETE TOPIC;');
36
- // });
37
- // await client.ksql('DROP STREAM IF EXISTS TESTJESTSTREAM DELETE TOPIC;');
38
-
39
- /* const pushTest = async () => {
23
+ /* const pushTest = async () => {
40
24
try {
41
25
metadata = await client.push('SELECT * FROM riderlocations EMIT CHANGES LIMIT 1;', (row) => console.log(row));
42
26
console.log('this is the metadata returned ', metadata);
43
27
} catch (error) {
44
28
console.log(error);
45
29
}
46
-
47
- metadata = await client.push('SELECT * FROM riderlocations EMIT CHANGES LIMIT 1;', (row) => console.log(row));
48
- console.log('this is the metadata returned ', metadata);
49
-
50
- metadata = await client.push('SELECT * FROM riderlocations EMIT CHANGES LIMIT 1;', (row) => console.log(row));
51
- console.log('this is the metadata returned ', metadata);
52
30
};
53
31
54
- pushTest();
32
+ pushTest(); */
55
33
56
34
//---------------------Test Termination of Queries-------------------
57
35
/* const terminateTest = async () => {
@@ -71,11 +49,11 @@ setTimeout(() => terminateTest(metadata), 2000); */
71
49
listQueries(); */
72
50
73
51
//---------------------Test Stream Creation-------------------
74
- // const createStreamTest = () => {
75
- // client.createStream('TestStream', ['name VARCHAR', 'email varchar', 'age INTEGER'], 'testTopic', 'json', 1);
76
- // }
52
+ /* const createStreamTest = () => {
53
+ client.createStream('TestStream', ['name VARCHAR', 'email varchar', 'age INTEGER'], 'testTopic', 'json', 1);
54
+ }
77
55
78
- // createStreamTest();
56
+ createStreamTest(); */
79
57
80
58
//---------------------Test Table Creation-------------------
81
59
/* const createTableTest = () => {
@@ -85,45 +63,42 @@ listQueries(); */
85
63
createTableTest(); */
86
64
87
65
//---------------------Test Insert Stream-------------------
88
- /* const insertStreamTest = () => {
89
- client.insertStream('TestStream', [
90
- { "name": "matt", "email": "123@mail .com", "age": 1000 },
91
- { "name": "jonathan", "email": "234@mail .com", "age": 99 }
92
- ]);
93
- /* const insertStreamTest = async () => {
66
+ /* const insertStreamTest = async () => {
94
67
const test = await client.insertStream('TestStream', [
95
68
{ "name": "matt", "email": "123@mail .com", "age": 1000 },
96
69
{ "name": "jonathan", "email": "234@mail .com", "age": 99 }
97
70
]);
98
71
console.log('returned array: ', test);
99
- */
100
-
101
- const insertStreamTest = async ( ) => {
102
- // const test = await client.insertStream('TestStream', [
103
- // { "name": "Scrooge", "email": "mcduck@mail.com", "age": 59 },
104
- // { "name": "jonathan", "email": "234@mail.com", "age": 99 }
105
- // ]);
106
- // console.log('returned array: ', test);
107
- } ;
108
-
109
- // insertStreamTest();
72
+ };
73
+ insertStreamTest(); */
110
74
111
- const pullFromToTest = async ( ) => {
75
+ /* const pullFromToTest = async () => {
112
76
const data = await client.pullFromTo('TESTSTREAM', 'America/Los_Angeles', ['2022-05-18', '00', '00', '00'], ['2022-05-20', '00', '00', '00']);
113
77
// console.log(data);
114
78
}
115
79
116
- pullFromTo ( ) ;
117
- // const insertStreamTest = async () => {
118
- // const test = await client.insertStream('TestStream', [
119
- // { "name": "matt", "email": "123@mail.com", "age": 1000 },
120
- // { "name": "jonathan", "email": "234@mail.com", "age": 99 }
121
- // ]);
122
- // // console.log('returned array: ', test);
123
- // };
80
+ pullFromTo(); */
81
+
82
+ //---------------------Test Stream Creation As-------------------
83
+
84
+ const createStreamAsTest = async ( ) => {
85
+ const queryId = await client . createStreamAs ( 'TestAsStream' , [ 'latitude' , 'longitude' ] , 'riderLocations' , {
86
+ kafka_topic : 'TestAsStream' ,
87
+ value_format : 'json' ,
88
+ partitions : 1
89
+ } ,
90
+ 'latitude > 37' ) ;
91
+ console . log ( 'this is the queryId: ' , queryId ) ;
92
+ } ;
124
93
125
- // insertStreamTest ();
94
+ createStreamAsTest ( ) ;
126
95
96
+ // (streamName, selectColumns, sourceStream, propertiesObj, conditionsObj)
97
+ // const defaultProps = {
98
+ // kafka_topic: streamName,
99
+ // value_format: 'json',
100
+ // partitions: 1
101
+ // };
127
102
128
103
//---------------------Test Inspect query status -------------------
129
104
// const inspectQueryStatusTest = async () => {
@@ -208,4 +183,4 @@ pullFromTo();
208
183
// // should return true
209
184
// };
210
185
211
- // isValidPropertyTest();
186
+ // isValidPropertyTest();
0 commit comments