Create table using description from the file - monetdb

Case:
I have csv data extract to be loaded with a great COPY INTO and also have a csv file with table description.
I want to create table from this description file before loading data.
Q:Is it possible to create a table by using description file?
I looked at 'CREATE TABLE mytable FROM LOADER myloader();' example but it does not seem support additional attributes to define columns.
One solution I know is to create a Python function to parse file and generate ddl statement but was curios if it can be done easier way.
Idea for enhancement: COPY INTO would be expanded to support creating tables at the same time by adding description file as another parameter.

Unfortunately, this is not currently possible.
The problem from my experience with implementing this kind of convenience feature is that it would be difficult to define a syntax that:
is backward compatible so that it does not break existing code
convenient for a majority of users
simple enough to implement

Related

Sqitch - single plan row, multiple sql files

I'm looking to move to sqitch, but my team likes their migrations as multiple files. That is, for example, if we create a foreign key and create an index in the same jira ticket, we like PROJ-123-create-fk.sql and PROJ-123-create-index.sql.
I'd like to keep a single row in the sqitch.plan file, so that each jira ticket corresponds to a single row.
Basically, short of adding lines to sqitch.plan, can I do this? Is there a way to "include" other sql files from a master one? Something like
PROJ-123-main.sql
\include PROJ-123-create-fk.sql
\include PROJ-123-create-index.sql
Thanks so much!
The \ir psql directive solved this for me.
in PROJ-123-deploy.sql
\ir PROJ-123-create-fk.sql
\ir PROJ-123-create-index.sql
If the fk and index sql files are in the same directory, they will be executed.
Since you want to store it as a single line in the plan file, it doesn't quite match, but I will explain the method we use below. Maybe there are parts that you want to use in it.
There is a similar situation in my team, but we use sqitch tags. Each version of our application corresponds to a subtask. And each task corresponds to a tag. We create sql files as many as the number of subtasks. Then we combine them in a tag that we created with the name of the main task. In our CI/CD pipeline that we use for the database, we also provide the transition between versions with tags. I wanted to add this method here in case anyone prefers to use a similar structure.
Simple example;
Let's have v2.0 of our application installed and a new table and an index are required for v2.1
We create two subtasks named create table and create index under the main task named v2.1
We create two sql files;
app_v2.1_table_create.sql to create a table, app_v2.1_index_create.sql to create an index.
After that, we create a sqitch tag called v2.1. Notice it has the same name as the main task.

How to compare dmn xml files and show the diff of decision tables

I would like to know is there any tool is available to compare dmn xml files and show the diff of decision tables.
I want to implement diff viewer for dmn xml files to show the diff of decision table using javascript. It would be greatly helpful if you provide any reference for already available diff viewer applications or any javascript npm plugins or any implementation using any language.
Let's consider below example. If decision table name is changed then I want to show only diff of name instead entire table, because if we change name of the table then the id will change. So it is difficult to find the table once we change the table name.
here is Jozef, a quality engineer for the DMN editor on the screenshot. Unfortunately there is currently no plan for a feature you describe in your question. Feel free to create a jira in https://issues.redhat.com/projects/KOGITO/issues

Update view schema

Hi I would like to be able to update a view to point to a table in a different schema as in example below, change SCHEMA1 to SCHEMA2. No other change to the SQL.
Can anyone suggest an efficient way to achieve this, ideally a string replacement.
I can do CREATE OR REPLACE FORCE VIEW and provide the list of fields. This doesn't seem a good option as I have about 40 views re repoint.
CREATE OR REPLACE FORCE VIEW CUST.CustOrdersView as
SELECT field1, field2 etc.. from
SCHEMA1.CUSTOMER ;
Your problem is simply that you have hardcoded the schema name in the views' queries. Instead of that you could have created a synonym:
create synonym CUSTOMER for SCHEMA1.CUSTOMER;
Then in your view you would have simply referenced CUSTOMER.
To repoint the view to another schema you would have to change the synonyms:
create or replace synonym CUSTOMER for SCHEMA2.CUSTOMER;
That's still work but it's much easier to generate those statements from the data dictionary views than it is to change all the view queries.
(If there is a namespace clash - that is, if schema which owns the views already has an object called CUSTOMER - you would need to use a different name for the schema.)
You may not regard this as a helpful answer, because it doesn't really solve your current problem, but it may help you avoid a similar situation in the future.

ODI 11g Interface SQL Data to Multiple Flat Files

Is it possible to create an ODI interface that creates multiple flat files based off unique records in a SQL table? There is plenty of information out there regarding how to interface multiple flat files into one SQL datastore - but is it possible the other way around?
Not sure we can tell the interface to create dynamic models based off when certain SQL data primary key data value change for example on a given table? So 600 records with 600 different data points at the PK column corresponding to 600 different rows creates 600 flat files?
Just typing this makes me think the answer is a FIRM NO.
I think you can do it.
Minimal steps with minimal informations:
Create a Package;
Create a loop in the package (For i = 0; i
Inside the loop you will setup the name of the file that will be generate (variable);
Still inside the loop, setup the filter that is used into the interface (variable);
Still inside the loop, run the interface.
Additional setup.
For the interface you will need two models:
for the source
for the target
In the model of the target (Technology File) you will need to setup the name of the file. Instead a static name, you will put a project/global variable. That variable you will setup during the loop. So, each time you will loop, you will have a different name.
I tried to be clear and short in the same time. I can expand my explication and give you an example.
If I didn't understood well, please tell me.

Store translated versions in database for Joomla component

I'm currently developing my first MVC component for Joomla 3.x. All in all I'm bit struggling with language/translation issues in database.
My problem is that I need to store translated content of user generated content which comes from the backend. For example someone enters a new item in German (stored in database) and needs a translation in another language. How to accomplish that in Joomla? I don't like to generate a new item for every different language when the rest is all the same.
I thought about a table "item" and a table "item_language" with that structure (strongly simplified for viewing purposes):
item
id PRIMARY INT
price DOUBLE(4,2)
item_language
itemid PRIMARY INT
language PRIMARY CHAR(5)
name VARCHAR(50)
In item_language I would like to store the different translated versions. In the language field there would be the region code (eg. de-DE) to identify the language.
My problems:
How to display the different (translated) versions in backend?
Is this the right database model?
Any help is appreciated!
You have really found yourself a nice task for a first component in Joomla!
A rather generalist answer:
The database model seems right. Alternatively you could encode in JSON the language data, but this could make later query operations potentially difficult. This way you will only have one table to work with.
As far as I know (if you are using JModel / JTable to manipulate the data) can't do this directly, as JTable is really only designed to manipulate single tables.
What you can do:
For editing: figure a way to represent this graphically ( for your users to see and edit this one to many relationship) and to post this data (language texts as an array) to JModel. In the model you can maintain the desired relationships and save the data using JTable.
Viewing (without editing) shouldn't be an issue, it would be a simple JOIN.
If you are willing to create a basic component on github, I might even give you a hand with JModel / JTable.
I found a way to deal with the things I needed.
Thanks Valentin Despa for guiding me in the right direction :-).
Here the whole procedure (simplified - validations and exact steps omitted):
Define the form fields in the models/forms/site.xml as normal.
In views/site/tmpl/edit.php add self coded Javascript (based on jQuery) to deal with the fields which have content in multiple languages stored as JSON in database.
Clone the original form element and modify the needed attributes (id, name, ...) to display a special version just for the defined languages. As content - extract the JSON for the needed language from original field content and display.
Hide the original field with Javascript and append the customized versions to DOM.
Afterwards in tables/site.php I read the dynamically generated content withJInput and build together the original field by generating JSON and saving to database.
It's working like expected.

Resources