Calling Talend Cloud Rest API from Apache Drill via sql

2022-02-04 | #apache #api #drill #rest #sql #sql #Talend

Abstract

I’ll show how to connect to Talend Cloud API via sql using Apache Drill.

drill

Download

Download Apache Drill from https://drill.apache.org/download/

Configure

Create or edit the file conf/storage-plugins-override.conf

"storage": {
  "talendcloud" : {
	"type" : "http",
	"cacheResults" : true,
	"connections" : {
	  "get" : {
		"url" : "https://api.eu.cloud.talend.com",
		"method" : "GET",
		"headers" : {
		  "Authorization" : "Bearer MYSECRETKEY"
		},
		"authType" : "none",
		"userName" : null,
		"password" : null,
		"postBody" : null,
		"params" : ["query"],
		"dataPath" : null,
		"requireTail" : true,
		"inputType" : "json",
		"xmlDataLevel" : 1
	  }
	},
	"proxyType" : "direct",
	"enabled" : true
  }
}

Start Drill

Run drill with

Continue reading 


aws-ext

2021-06-25 | #aws #programming #python

The aws_ext python package contains some useful functions (built on top of boto3) for managing some aws services. At the moment only some utilities for the Aws Glue Data catalog

Installation

pip install aws_ext

Usage

import boto3
import aws_ext

session = boto3.session.Session()

GLUE

from aws_ext import glue_databases
glue_client = session.client("glue")

Extracting tables with (too) many versions

glue_databases.get_tables_with_many_versions(glue_client, database_name="mydb", threshold=1)

Deleting old tables versions

glue_databases.delete_old_tables_versions(glue_client, database_name="mydb", keep=1, dryrun=True)

Continue reading 


Where is gold challenge with Prolog

2021-06-02 | #programming #prolog

My #prolog solution for “Where is gold?” proposed by dmcommunity.org challenge Jun 2021: 0 means empty, 1 means gold

?- solution(Box1,Box2,Box3).
Box1 = Box3, Box3 = 0,
Box2 = 1.

below the code

:-use_module(library(clpfd)).

sentence1(    1,_Box2,_Box3).
not_sentence1(0,_Box2,_Box3).

sentence2(    _Box1,0,_Box3).
not_sentence2(_Box1,1,_Box3).

sentence3(    0,_Box2,_Box3).
not_sentence3(1,_Box2,_Box3).

true_only_one_sentence(Box1, Box2, Box3):-
	(       sentence1(Box1,Box2,Box3), not_sentence2(Box1,Box2,Box3), not_sentence3(Box1,Box2,Box3) ) ;
	(   not_sentence1(Box1,Box2,Box3),     sentence2(Box1,Box2,Box3), not_sentence3(Box1,Box2,Box3) ) ;
	(   not_sentence1(Box1,Box2,Box3), not_sentence2(Box1,Box2,Box3),     sentence3(Box1,Box2,Box3) ).

solution(Box1, Box2, Box3):-
	Box1 in 0..1, /* 0 empty, 1 gold */
	Box2 in 0..1,
	Box3 in 0..1,
	Box1 + Box2 + Box3 #= 1, /* only one box contains gold */
	true_only_one_sentence(Box1, Box2, Box3).

Continue reading 