i'm importing json data to cassandra. Here is one of my table :
CREATE TABLE Geometry (
id TEXT, type TEXT, coordinates LIST<FLOAT>,
primary key (id)
);
As you can see I have coordinates which is a list of 3 elements like: [-12, 123, 4].
I would like to know if it's possible in Cassandra to retrieve only the last element of coordinates to do a query like :
select coordinates[2] from geometry where id='nc72001620';
Which would retrieve me 4 in my example.
Note that I could change coordinates to a set if it's necessary.
Thank you !
Related
I'm using Teiid 9.3.7 with Wildfly 10 due to Teiid Designer version compatibility. I'm trying to build a view out of a flat file. There are two different types of entries in the file. Each type of entry has a key attribute that I need in order to join with other tables, but the position of the key attribute are different for each type of entries. The first number(4) will tell me which kind of entry is that row. I imported the data source and parse each row the same way, so I can catch the key attribute from both types of entries but as different columns. The transformation of the view looks like this
SELECT
A.TYPE, A.column_1, A.ID, A.column_2, A.KEY_ATTRIB_1, A.column_3, A.KEY_ATTRIB_2, A.column_4
FROM
(EXEC CorrSourceModel.getTextFiles('my_input.txt')) AS f, TEXTTABLE(f.file COLUMNS TYPE string WIDTH 4, column_1 string WIDTH 32, ID string WIDTH 9, column_2 string WIDTH 2466, KEY_ATTRIB_1 string WIDTH 25, column_3 string WIDTH 1445, KEY_ATTRIB_2 string WIDTH 13, column_4 string WIDTH 2854) AS A
So in the view, I can see both key attributes in their column fine. The final virtual view schema I need to build is the original line of the row, the key attribute of that row, and additional attributes I join from another data source with that key attribute. So in order to do that, I need to test the first attribute (4-digit number) so I know witch column is my key attribute for the row. It's like I need a IF... ELSE statement.
If there a way to accomplish that? Thanks.
See SELECTOR in this document [1] that should let you pick the lines. You can have two TEXTTABLE constructs one for each SELECTOR type and then join them if needed to get a combined result.
[1] http://teiid.github.io/teiid-documents/master/content/reference/r_texttable.html
I noticed that DynamoDB query/scan only returns documents that contain a subset of the document, just the key columns it appears.
This means I need to do a separate Batch_Get to get the actual documents referenced by those keys.
I am not using a projection expression, and according to the documentation this means the whole item should be returned.1
How do I get query to return the entire document so I don't have to do a separate batch get?
One example bit of code that shows this is below. It prints out found documents, yet they contain only the primary key, the secondary key, and the sort key.
t1 = db.Table(tname)
q = {
'IndexName': 'mysGSI',
'KeyConditionExpression': "secKey= :val1 AND " \
"begins_with(sortKey,:status)",
'ExpressionAttributeValues': {
":val1": 'XXX',
":status": 'active-',
}
}
res = t1.query(**q)
for doc in res['Items']:
print(json.dumps(doc))
This situation is discussed in the documentation for the Select parameter. You have to read quite a lot to find this, which is not ideal.
If you query or scan a global secondary index, you can only request
attributes that are projected into the index. Global secondary index
queries cannot fetch attributes from the parent table.
Basically:
If you query the parent table then you get all attributes by default.
If you query an LSI then you get all attributes by default - they're retrieved from the projection in the LSI if all attributes are projected into the index (so that costs nothing extra) or from the base table otherwise (which will cost you more reads).
If you query or scan a GSI, you can only request attributes that are projected into the index. GSI queries cannot fetch attributes from the parent table.
I have a issue in Oracle Apex Data Load which I will try to explain in a simple way:
I want to copy csv data (copy/paste) in Data Load Application and apply the transformation, and rules and load the data into the table BIKE.
csv columns (type, amount-a, amount-b)
blue, 10, 100
green, 20, 200
table BIKE columns
(type, amount)
I want to create a transformation to check if the column value in the table BIKE is 'blue' then load amount-b other wise amount-a.
Can anyone help me on this?
Thanks
Create a staging table, e.g. like this (you will need to adjust the details of the columns to match your data model):
create table bike_staging
(
apex_session number not null,
bike_id number not null,
bike_type varchar2(100) not null,
amount_a number,
amount_b number
);
Add a trigger to populate session_id:
create or replace trigger bi_bike_staging
before insert on bike_staging for each row
begin
:new.apex_session := v('APP_SESSION');
end bi_bike_staging;
Add two processes to the third page of the data load wizard, on either side of the "Prepare Uploaded Data" process, like this:
The code for "delete staging table" will be like this:
delete bike_staging where apex_session = :APP_SESSION;
The code for "load bikes" may be something like this:
merge into bikes t
using (select bike_id,
bike_type,
case bike_type
when 'BLUE' then amount_b
else amount_a
end as amount
from bike_staging
where apex_session = :APP_SESSION
) s
on (t.bike_id = s.bike_id)
when matched then update set
t.bike_type = s.bike_type,
t.amount = s.amount
when not matched then insert (bike_id, bike_type, amount)
values (s.bike_id, s.bike_type, s.amount);
delete bike_staging where apex_session = :APP_SESSION;
Alternatively, if you are only inserting new records you don't need the merge, you can use a simple insert statement.
Trying to create a new query from the existing "Master" Query using below formula:
let
Source = Table.SelectColumns('Original Source Name',{'Column Name','Column Name2'})
in
Source
which works fine, however I am looking to see if there is any other formula which would do the same but in a way that it will create the new query with a range of columns , for example Column 30- 67 ( in this case when the original Excel file is updated, inserting a column in this range it would automatically update in the PBI too when refreshed)
Here's one possible way. If you start with this table, named Table1:
You can reference it in a new query like this:
let
Source = Table.SelectColumns(Table1, List.Range(Table.ColumnNames(Table1), 2, 3))
in
Source
...to get this:
The formula selects a range of columns from the table starting at the column at index position 2, and spanning 3 columns. (The index starts with 0.) For columns 30-67, you would change the 2 to 31 and the 3 to 37. You would change Table1 to your Original Source Name as well.
See these links for more info on List.Range and Table.ColumnNames.
I want to make a select list in apex in which when i select any number from select list then it displays diffrent column table for example when i select 1 then it display (bags) when select 2 it displays (trousers)...
I hope I understand your question right.
For a select list you need to create a list of values. There you have to fill two columns, the Display Value Column and the Return Value Column.
Like the label says, the Display Column is for displaying (like trousers, bags) and the return value returns another value (like 2, 1) to the database. On the database it won't be saved as trousers or bags, it will be saved as 2 and 1.
Hope this helped you.