You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "Hari-Durai-Baskar (via GitHub)" <gi...@apache.org> on 2024/01/12 05:07:33 UTC

[I] How to pass query context for eanbling window functions using druidapi in python code (druid)

Hari-Durai-Baskar opened a new issue, #15672:
URL: https://github.com/apache/druid/issues/15672

   example code:
   
   import druidapi
   import os
   
   if 'DRUID_HOST' not in os.environ.keys():
       druid_host=f"http://localhost:8888"
   else:
       druid_host=f"http://{os.environ['DRUID_HOST']}:8888"
       
   print(f"Opening a connection to {druid_host}.")
   druid = druidapi.jupyter_client(druid_host)
   
   display = druid.display
   sql_client = druid.sql
   
   query = """WITH HumidChange AS (SELECT device_id,__time,humidity,humidity - LAG(humidity) OVER (PARTITION BY device_id ORDER BY __time) AS humid_change FROM thermal_log) SELECT d.device_id,d.device_name,tc.__time,tc.humidity AS current_humidity, tc.humid_change FROM devices d JOIN HumidChange tc ON d.device_id = tc.device_id WHERE tc.humid_change >= 10"""
   
   display.sql(query)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org