Skip to content

Instantly share code, notes, and snippets.

import time
from locust import User, TaskSet, task, between, events
from trino.dbapi import connect
from trino import auth
from configparser import ConfigParser
config = ConfigParser()
config.read('config.ini')
trino_config = config['trino']
@posulliv
posulliv / extract_metrics.py
Created December 14, 2022 18:36
Python script to extract high level metrics from Trino explain plan generated with EXPLAIN ANALYZE
#!/usr/bin/env python3
from timeit import default_timer as timer
import configparser
import trino
import click
@click.command()
@click.option('--queries', type=click.Path(exists=True), help='SQL file with queries to extract metrics for.')
def run(queries):
@posulliv
posulliv / docker-compose.yml
Last active October 16, 2024 12:45
Simple demo of Trino HA using Nginx reverse proxy.
version: '3.3'
services:
trino_a:
image: trinodb/trino
container_name: trino_a
ports:
- 8080:8080
volumes:
- ./trino_a.config.properties:/etc/trino/config.properties
@Test
public void testPredicatePushdownWithDate()
{
String tableName = "predicate_test";
tester().getQueryRunner().execute(format("CREATE TABLE %s (a, b) AS SELECT DATE '2020-10-20', 6", tableName));
PushPredicateIntoTableScan pushPredicateIntoTableScan = new PushPredicateIntoTableScan(
tester().getMetadata(),
new TypeOperators(),
tester().getTypeAnalyzer());
@posulliv
posulliv / presto.patch
Created October 12, 2020 14:46
Patch for Apache Atlas version 2.1.0 to allow Hive Metastore hook to work correctly with Presto.
--- addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveMetastoreHookImpl.java 2020-10-12 09:54:29.000000000 -0400
+++ addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveMetastoreHookImpl.java.presto 2020-10-12 10:44:24.000000000 -0400
@@ -17,6 +17,8 @@
*/
package org.apache.atlas.hive.hook;
+import com.google.common.collect.MapDifference;
+import com.google.common.collect.Maps;
import org.apache.atlas.hive.hook.events.*;
import org.apache.atlas.hook.AtlasHook;
[ RECORD 4 ]-------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<?php
$test = '<div>(1) (4) (8) (22) (101)</div>';
$pattern = '/\((\d+)\)/';
$replacement = '<padraig>(${1})</padraig>';
echo preg_replace($pattern, $replacement, $test) . "\n";
?>
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 83.58  248.894290        2919     85260      6809 futex
  7.33   21.825363       81743       267           nanosleep
  6.16   18.341146       81156       226           select
  1.56    4.658605         119     39106           fsync
  1.08    3.216201      459457         7         6 restart_syscall
  0.14    0.413560          14     29478           munmap
  0.07    0.205368           7     29478           mmap
1955 __memset_sse2,os_aio_linux_collect(string3.h:85),os_aio_linux_handle(string3.h:85),fil_aio_wait(fil0fil.c:4620),io_handler_thread(srv0start.c:482),start_thread,clone,??
1386 pthread_cond_wait,toku_cond_wait(toku_pthread.h:294),kwait(toku_pthread.h:294),work_on_kibbutz(toku_pthread.h:294),start_thread,clone,??
397 pthread_cond_timedwait,toku_cond_timedwait(toku_pthread.h:310),minicron_do(toku_pthread.h:310),start_thread,clone,??
200 pthread_cond_wait,toku_cond_wait(toku_pthread.h:294),minicron_do(toku_pthread.h:294),start_thread,clone,??
200 pthread_cond_timedwait,toku_cond_timedwait(toku_pthread.h:310),evictor::run_eviction_thread(toku_pthread.h:310),eviction_thread(cachetable.cc:3615),start_thread,clone,??
200 pthread_cond_timedwait,os_cond_wait_timed(os0sync.c:171),os_event_wait_time_low(os0sync.c:171),srv_monitor_thread(srv0srv.c:2171),start_thread,clone,??
200 pthread_cond_timedwait,os_cond_wait_timed(os0sync.c:171),os_event_wait_time_low(os0sync.c:171),srv_lock_timeout_thre
1943 __memset_sse2,os_aio_linux_collect(string3.h:85),os_aio_linux_handle(string3.h:85),fil_aio_wait(fil0fil.c:4620),io_handler_thread(srv0start.c:482),start_thread,clone,??
1379 pthread_cond_wait,toku_cond_wait(toku_pthread.h:294),kwait(toku_pthread.h:294),work_on_kibbutz(toku_pthread.h:294),start_thread,clone,??
388 pthread_cond_timedwait,toku_cond_timedwait(toku_pthread.h:310),minicron_do(toku_pthread.h:310),start_thread,clone,??
200 pthread_cond_wait,toku_cond_wait(toku_pthread.h:294),toku_thread_run_internal(toku_pthread.h:294),start_thread,clone,??
200 pthread_cond_wait,toku_cond_wait(toku_pthread.h:294),minicron_do(toku_pthread.h:294),start_thread,clone,??
200 pthread_cond_timedwait,toku_cond_timedwait(toku_pthread.h:310),evictor::run_eviction_thread(toku_pthread.h:310),eviction_thread(cachetable.cc:3615),start_thread,clone,??
200 pthread_cond_timedwait,os_cond_wait_timed(os0sync.c:171),os_event_wait_time_low(os0sync.c:171),srv_monitor_thread(srv0srv.c:2171),start_thread,clone