List Clusters using SQL - orientdb

OrientDB manual shows how to obtain CLUSTER information using the console.
For example, to obtain a list of Clusters, i would do:
orientdb> LIST CLUSTERS
But, i cannot find how to obtain the same information using SQL.
Is there a way to obtain a list of all the Clusters using SQL?
(I'm using OrientDB 2.2.29).

You can use something like:
select name as NAME, clusterIds as ID from (select expand(classes) from metadata:schema)

Related

How do I query Postgresql with IDs from a parquet file in an Data Factory pipeline

I have an azure pipeline that moves data from one point to another in parquet files. I need to join some data from a Postgresql database that is in an AWS tenancy by a unique ID. I am using a dataflow to create the unique ID I need from two separate columns using a concatenate. I am trying to create where clause e.g.
select * from tablename where unique_id in ('id1','id2',id3'...)
I can do a lookup query to the database, but I can't figure out how to create the list of IDs in a parameter that I can use in the select statement out of the dataflow output. I tried using a set variable and was going to put that into a for-each, but the set variable doesn't like the output of the dataflow (object instead of array). "The variable 'xxx' of type 'Array' cannot be initialized or updated with value of type 'Object'. The variable 'xxx' only supports values of types 'Array'." I've used a flatten to try to transform to array, but I think the sync operation is putting it back into JSON?
What a workable approach to getting the IDs into a string that I can put into a lookup query?
Some notes:
The parquet file has a small number of unique IDs compared to the total unique IDs in the database.
If this were an azure postgresql I could just use a join in the dataflow to do the join, but the generic postgresql driver isn't available in dataflows. I can't copy the entire database over to Azure just to do the join and I need the dataflow in Azure for non-technical reasons.
Edit:
For clarity sake, I am trying to replace local python code that does the following:
query = "select * from mytable where id_number in "
df = pd.read_parquet("input_file.parquet")
df['id_number'] = df.country_code + df.id
df_other_data = pd.read_sql(conn, query + str(tuple(df.id_number))
I'd like to replace this locally executing code with ADF. In the ADF process, I have to replace the transformation of the IDs which seems easy enough if a couple of different ways. Once I have the IDs in the proper format in a column in a dataset, I can't figure out how to query a database that isn't supported by Data Flow and restrict it to only the IDs I need so I don't bring down the entire database.
Due to variables of ADF only can store simple type. So we can define an Array type paramter in ADF and set default value. Paramters of ADF support any type of elements including complex JSON structure.
For example:
Define a json array:
[{"name": "Steve","id": "001","tt_1": 0,"tt_2": 4,"tt3_": 1},{"name": "Tom","id": "002","tt_1": 10,"tt_2": 8,"tt3_": 1}]
Define an Array type paramter and set its default value:
So we will not get any error.

Grafana Reference DataSet Variable to Translate Legend Values using Postgres Driver

I have a postgres data-source in Grafana that's normalized which restricts my graph-visualization legend to show only the ID (hash) of my record. I want to make this human-readable but the id -> name mapping is in a different datasource/postgres database.
Grafana supports templating-variables which I think could allow me to load my id -> naming reference data but there isn't clear documentation on how to access the label_values as a reference-table within the postgres driver's query editor.
Is there a way to configure the template variable to load reference data (id -> name) & leverage it to translate my metric/legend ids within the grafana postgres driver?
For Example (pseudo-grafana postgres query editor):
SELECT
$__timeGroupAlias(start,$__interval),
animal_names.__value AS metric,
count(dog.chewed_bones) AS “# bones chewed“
FROM animals.dog dog
JOIN $TEMPLATE_VAR_REF_DATA animal_names ON dog.id = animal_names.__text
WHERE $__timeFilter(start_time)
GROUP BY 1,2
ORDER BY 1,2
Closest answer I found is here but doesn't get into details:
johnymachine's comment # https://github.com/grafana/grafana/issues/1032
I realized the github comment meant use a jsonb aggregate function as a variable like in the following solution:
Dashboard Variable (Type Query): select jsonb_object_agg(id,name) from animal_names;
Grafana Postgres Pseudo-Query:
SELECT
$__timeGroupAlias(start,$__interval),
animal_names::jsonb ->> dog.id::text AS metric,
count(dog.chewed_bones) AS “# bones chewed“
FROM animals.dog
WHERE $__timeFilter(start_time)

Join on Apache Ignite REST API

Does anyone know if you can do a join using the REST API for Apache Ignite? I have two objects, account and customer loaded to the Apache Ignite Server. Both objects are loaded with data and stored in the cache as account object cache and customer object cache. I am able to query both objects separately using the REST API, i.e.
http://localhost:8080/ignite?cmd=qryfldexe&pageSize=1000&cacheName=CustomerCache&qry=select+id+from+customer
http://localhost:8080/ignite?cmd=qryfldexe&pageSize=1000&cacheName=AccountCache&qry=select+id+from+account
However, I would like to execute a join on the account and customer cache. Is this supported and if so, does anyone have any examples? I can't find any documentation on this.
You need to specify one cache in the cacheName, and reference the second table in the JOIN via its schema name (by default it's the cache name). That's not unique to the REST API, Java API works in the same way.
The query should be something like
SELECT *
FROM Customer AS c
JOIN AccountCache.Account AS a
WHERE c.id = a.customerId
Try to use qryfldexe:
For example, I create next caches:
http://apache-ignite-users.70518.x6.nabble.com/file/t1704/ss1.java
It creates two caches with the same structure.
Now I am going to execute next command:
SELECT * FROM "mycache1".Value V1 join "mycache2".Value V2 on V1.key=V2.key
Let's use next converter to get URI string:
https://meyerweb.com/eric/tools/dencoder/
Our command will be next:
SELECT%20*%20FROM%20%22mycache1%22.Value%20V1%20join%20%22mycache2%22.Value%20V2%20on%20V1.key%3DV2.key
Run next in brouser:
http://127.0.0.1:8080/ignite?cmd=qryfldexe&pageSize=10&cacheName=mycache1&qry=SELECT%20*%20FROM%20%22mycache1%22.Value%20V1%20join%20%22mycache2%22.Value%20V2%20on%20V1.key%3DV2.key
Output:
{"successStatus":0,"error":null,"response":{"items":[[0,"Value 0",0,"Value
0"],[1,"Value 1",1,"Value 1"],[2,"Value 2",2,"Value 2"],[3,"Value
3",3,"Value 3"],[4,"Value 4",4,"Value 4"],[5,"Value 5",5,"Value
5"],[6,"Value 6",6,"Value 6"],[7,"Value 7",7,"Value 7"],[8,"Value
8",8,"Value 8"],[9,"Value 9",9,"Value
9"]],"last":false,"queryId":10,"fieldsMetadata":[{"schemaName":"mycache1","typeName":"VALUE","fieldName":"KEY","fieldTypeName":"java.lang.Integer"},{"schemaName":"mycache1","typeName":"VALUE","fieldName":"VALUE","fieldTypeName":"java.lang.String"},{"schemaName":"mycache2","typeName":"VALUE","fieldName":"KEY","fieldTypeName":"java.lang.Integer"},{"schemaName":"mycache2","typeName":"VALUE","fieldName":"VALUE","fieldTypeName":"java.lang.String"}]},"sessionToken":null}

How does one select the server name in a sys objects query

In T-SQL, I am trying to do something like :-
select * from [server_name].dbo.sys.objects
but I keep getting the error 'Invalid object name..'
I ultimately want to compare all the databases of the two servers
(something like the following..):--
Select * from [server1].dbo.Sys.Databases d1
cross join [server2].dbo.Sys.Databases d2
on d1.database_id = d2.database_id
You can use linked servers to select data from databases on two different servers within a single query.
You can set up linked servers through SQL Server Mangement Studio under Server Objects --> Linked Servers. Once you have linked [server1] to [server2] you should be able to execute your query.
Use this.
select from [server_name].[base_name].sys.objects

Tableau Extract API with multiple tables in a database

I am currently experimenting with Tableau Extract API to generate some TDE from the tables I have in a PostgreSQL database. I was able to write a code to generate the TDE from single table, but I would like to do this for multiple joined tables. To be more specific, if I have two tables that are inner joined by some field, how would I generate the TDE for this?
I can see that if I am working with small number of tables, I could use a SQL query with JOIN clauses to create a one gigantic table, and generate the TDE from that table.
>> SELECT * FROM table_1 INNER JOIN table_2
INTO new_table_1
ON table_1.id_1 = table_2.id_2;
>> SELECT * FROM new_table_1 INNER JOIN TABLE_3
INTO new_table_2
ON new_table_1.id_1 = table_3.id_3
and then generate the TDE from new_table_2.
However, I have some tables that have over 40 different fields, so this could get messy.
Is this even a possibility with current version of the API?
You can read from as many tables or other sources as you want. Or use complex query with lots of joins, or create a view and read from that. Usually, creating a view is helpful when you have a complex query joining many tables.
The data extract API is totally agnostic about how or where you get the data to feed it -- the whole point is to allow you to grab data from unusual sources that don't have pre-built drivers for Tableau.
Since Tableau has a Postgres driver and can read from it directly, you don't need to write a program with the data extract API at all. You can define your extract with Tableau Desktop. If you need to schedule automated refreshes of the extract, you can use Tableau Server or its tabcmd command.
Many thanks for your replies. I am aware that I could use Tableau Desktop to define my extract. In fact, I have done this many times before. I am just trying to create the extracts using the API, because I need to create some calculated fields, which is near impossible to create using the Tableau Desktop.
At this point, I am hesitant to use JOINs in the SQL query because the resulting table would look too complicated to comprehend (some of these tables also have same field names).
When you say that I could read from multiple tables or sources, does that mean with the Tableau Extract API? At this point, I cannot find anywhere in this API that accommodates multiple sources. For example, I know that when I use multiple tables in the Tableau Desktop, there are icons on the left hand side that tells me that the extract is composed of multiple tables. This just doesn't seem to be happening with the API, which leaves me stranded. Anyways, thank you again for your replies.
Going back to the topic, this is something that I tried few days ago on my python code
try:
tdefile= tde.Extract("extract.tde")
except:
os.remove("extract.tde")
tdefile = tde.Extract("extract.tde")
tableDef = tde.TableDefinition()
# Read each column in table and set the column data types using tableDef.addColumn
# Some code goes here...
for eachTable in tableNames:
tableAdd = tdeFile.addTable(eachTable, tableDef)
# Use SQL query to retrieve bunch_of_rows from eachTable
for some_row in bunch_of_rows:
# Read each row in table, and set the values in each column position of each row
# Some code goes here...
tableAdd.insert(some_row)
some_row.close()
tdefile.close()
When I execute this code, I get the error that eachTable has to be called "Extract".
Of course, this code has its flaws, as there is no where in this code that tells how each table are being joined.
So I am little thrown off here, because it doesn't seem like I can use multiple tables unless I use JOINs to generate one table that contains everything.