Skip to content

Instantly share code, notes, and snippets.

# twitter api credentials
access_token=...
access_token_secret=...
consumer_key=...
consumer_secret=...
class TweetListener(StreamListener):
def __init__(self, stream_name):
self.kinesis = boto3.client('kinesis')
self.stream_name = stream_name
import boto3
kinesis = boto3.client('kinesis') # requires AWS credentials to be present in env
kinesis.create_stream(StreamName='twitter-stream', ShardCount=5)
rockset> select typeof(mof.c2)
from new_collection, unnest(new_collection."my-other-field") as mof;
+-----------+
| ?typeof |
|-----------|
| int |
| string |
+-----------+
rockset> select mof.*
from new_collection, unnest(new_collection."my-other-field") as mof;
+------------+-------+------+---------+
| c1 | c2 | c3 | c4 |
|------------+-------+------+---------|
| unexpected | 99 | 100 | 101 |
| this | field | has | changed |
+------------+-------+------+---------+
rockset> select mof.*
from new_collection, unnest(new_collection."my-other-field") as mof;
+------+-------+------+---------+
| c1 | c2 | c3 | c4 |
|------+-------+------+---------|
| this | field | has | changed |
+------+-------+------+---------+
rockset> select "my-field", "my-other-field"
from new_collection;
+------------+---------------------------------------------------------------+
| my-field | my-other-field |
|------------+---------------------------------------------------------------|
| doc1 | some text |
| doc2 | [{'c1': 'this', 'c2': 'field', 'c3': 'has', 'c4': 'changed'}] |
+------------+---------------------------------------------------------------+
rockset> select "my-field", "my-other-field"
from new_collection;
+------------+------------------+
| my-field | my-other-field |
|------------+------------------|
| doc1 | some text |
+------------+------------------+
@kleong
kleong / lambda_function.py
Created January 8, 2019 18:51
Rockset example Lambda function
from rockset import Client, Q
from lambdarest import lambda_handler
from credentials import API_KEY
import json
rs = Client(api_key=API_KEY,
api_server='https://api.rs2.usw2.rockset.com')
def lambda_handler(event, context):
if 'queryStringParameters' in event: