How do I load a csv file into actian table? - vectorwise

The "copy" command is successful, but junk data is loaded into the table.
"vwload" command errors out with a message "No table name specified".
How do I load a csv file into actian table?
* COPY TABLE airport2 () FROM '/tmp/head.csv' \g
* select * from airport2\g
qqqqqqqqqqqqqqqqqqqqqqqqqqqj
(1 row)
continue
$ /opt/Actian/VectorVW/ingres/bin/vwload –f "," –q "\"" –s 1 –l t1.log –t airport1 test /tmp/head.csv
No table name specified
Usage: vwload [options] database file ...
Try vwload --help
Update
This copy command does not complete. It shows "Excuting..." but there is no response after that, I have to kill the session.
$ /opt/Actian/VectorVW/ingres/bin/sql test
continue
* copy table airport2 (
* m1 = char(0) comma,
* d1 = char(0) comma,
* s1 = char(0) comma,
* m2 = char(0) comma,
* m3 = char(0) comma,
* sent_date = char(0) comma,
* stat = char(0) comma,
* done_date = char(0) comma,
* params_err = char(0) nl)
* from /tmp/head.csv \g
Executing . . .

There is no such thing as an 'actian table'. Action is a company which has bought several databases. (https://www.actian.com/product-overview/)
Unfortunately they do no make things easy, but you seem to be using 'ACtian X' (https://www.actian.com/data-management/actian-x-hybrid-rdbms/), or an older version of that.
The documentation is one thing they have!, It's available online, search their website ...

Related

Snowflake Store Procedure - Loop through csv files in AWS S3 and COPY INTO tables with same name

I was wondering if someone could help me with the error message I am getting from Snowflake. I am trying to create a stored procedure that will loop through 125 files in S3 and copy into the corresponding tables in Snowflake. The names of the tables are the same names as the csv files. In the example I only have 2 file names set up (if someone knows a better way than having to liste all 125, that will be extremely. helpful) .
The error message I am getting is the following:
syntax error line 5 at position 11 unexpected '1'.
syntax error line 6 at position 22 unexpected '='. (line 4)
CREATE OR REPLACE PROCEDURE load_data_S3(file_name VARCHAR,table_name VARCHAR)
RETURNS VARCHAR
LANGUAGE SQL
AS
$$
BEGIN
FOR i IN 1 to 2 LOOP
CASE i
WHEN 1 THEN
SET file_name = 'file1.csv';
SET table_name = 'FILE1';
WHEN 2 THEN
SET file_name = 'file2.csv';
SET table_name = 'FILE2';
--WILL LIST THE REMAINING 123 WHEN STATEMENTS
ELSE
-- Do nothing
END CASE;
COPY INTO table_name
FROM #externalstg/file_name
FILE_FORMAT = (type='csv');
END LOOP;
RETURN 'Data loaded successfully';
END;
$$;
There are various ways to list the files in a stage (see the post here). You can loop through the resultset and run COPY INTO on each record

Jenkins: How to set a schedule for a parametrized job?

I want to set a schedule for a parametrized Jenkins job to start in different time with different parameters, but I can not find the correct syntax for this. I would like to have something like that:
30 1 * * * % VAR1=VALUE1, VAR2=VALUE2
30 2 * * * % VAR1=VALUE3, VAR2=VALUE4
How to do it correctly?
The answer is in the plugin README:
parameterized-scheduler-plugin README.md
# leave spaces where you want them around the parameters. They'll be trimmed.
# we let the build run with the default name
5 * * * * % furniture=chair;color=black
# now, let's override that default name and use Mr. Rubble.
10 * * * * % furniture=desk; color=yellow; name=barney
Not explicitly documented, but the example and the code show it to be PAIR_SEPARATOR= ";"
See also this "bug" - JENKINS-22129 and JENKINS--53220 and more

LUA: How to Create 2-dimensional array/table from string

I see several posts about making a string in to a lua table, but my problem is a little different [I think] because there is an additional dimension to the table.
I have a table of tables saved as a file [i have no issue reading the file to a string].
let's say we start from this point:
local tot = "{{1,2,3}, {4,5,6}}"
When I try the answers from other users I end up with:
local OneDtable = {"{1,2,3}, {4,5,6}"}
This is not what i want.
how can i properly create a table, that contains those tables as entries?
Desired result:
TwoDtable = {{1,2,3}, {4,5,6}}
Thanks in advance
You can use the load function to read the content of your string as Lua code.
local myArray = "{{1,2,3}, {4,5,6}}"
local convert = "myTable = " .. myArray
local convertFunction = load(convert)
convertFunction()
print(myTable[1][1])
Now, myTable has the values in a 2-dimensional array.
For a quick solution I suggest going with the load hack, but be aware that this only works if your code happens to be formatted as a Lua table already. Otherwise, you'd have to parse the string yourself.
For example, you could try using lpeg to build a recursive parser. I built something very similar a while ago:
local lpeg = require 'lpeg'
local name = lpeg.R('az')^1 / '\0'
local space = lpeg.S('\t ')^1
local function compile_tuple(...)
return string.char(select('#', ...)) .. table.concat{...}
end
local expression = lpeg.P {
'e';
e = name + lpeg.V 't';
t = '(' * ((lpeg.V 'e' * ',' * space)^0 * lpeg.V 'e') / compile_tuple * ')';
}
local compiled = expression:match '(foo, (a, b), bar)'
print(compiled:byte(1, -1))
Its purpose is to parse things in quotes like the example string (foo, (a, b), bar) and turn it into a binary string describing the structure; most of that happens in the compile_tuple function though, so it should be easy to modify it to do what you want.
What you'd have to adapt:
change name for number (and change the pattern accordingly to lpeg.R('09')^1, without the / '\0')
change the compile_tuple function to a build_table function (local function build_tanle(...) return {...} end should do the trick)
Try it out and see if something else needs to be changed; I might have missed something.
You can read the lpeg manual here if you're curious about how this stuff works.

Assets:precompile fails because a '/' character in .js file is interpreted as the beginning of a regex

Pushing my code to Heroku fails with this error:
SyntaxError: Invalid regular expression: / (this.sample_rate /: Unterminated group
(in /tmp/build_3iv6pbfccqx1r/app/assets/javascripts/application.js)
It occurs during rake assets:precompile.
The line that causes this error looks like:
data[i] = Math.sin(this.x++ / (this.sample_rate / (this.frequency * 2 * Math.PI)));
and it's in a .js file under app/assets/javascripts. This is my only file where using the '/' character causes any problems.
The obvious but not necessarily best answer would be to split up that line some.
this.x++;
data[i] = Math.sin(this.x / (this.sample_rate / (this.frequency * 2 * Math.PI)));
Or
this.x++;
var t1 = this.frequency * 2 * Math.PI;
var t2 = this.sample_rate / t1;
var t3 = this.x / t2;
data[i] = Math.sin(t3);
Though I'm sure there are better variable names based on the underlying equation.
However, I am interested to see why this is happening. Does the JavaScript work locally?

Schedule nightly 22-03 build using Jenkins and H, the "hash symbol"

A build that takes about three hours to complete needs to be scheduled for nightly building outside office hours: not sooner than 22:00 and not later than 3:59 next day.
I'd also like to use the "H symbol" to avoid collision with future nightly builds. From in-line help in Jenkins:
To allow periodically scheduled tasks to produce even load on the system, the symbol H (for “hash”) should be used wherever possible. For example, using 0 0 * * * for a dozen daily jobs will cause a large spike at midnight. In contrast, using H H * * * would still execute each job once a day, but not all at the same time, better using limited resources.
(How) can I schedule this using Jenkins? What I've tried was all considered invalid by Jenkins:
H H(22,23,0,1,2,3) * * *
Invalid input: "H H(22,23,0,1,2,3) * * *": line 1:7: expecting "-", found ','
H H22,23,0,1,2,3 * * *
Invalid input: "H H22,23,0,1,2,3 * * *": line 1:4: unexpected token: 22
H H(22-3) * * *
Invalid input: "H H(22-3) * * *": line 1:9: 1 is an invalid value. Must be within 1
and -18
Is it possible to achieve this without using plug-ins?
I think the closest you will get is to use:
H H(0-3) * * * This will run at some point between 0:00 and 3:59
#midnight This will run at some point between 0:00 and 2:59
The H(4-8) construct only works if the second items is larger then the first.
But you might as well fill in the hour yourself. Jenkins actually never changes the hour the jobs runs once it is set. It will basically create some random hour once you save the job and always run the job at that particular time.
Of course, you can also file a bug report or feature request that you should be able to specify this as H(22-3) or better, fix the code and submit a patch ;)
There is no direct support to write the expression like this, but since there is timezone support (now), you can work around this.
# DONT COPY PASTE - THIS DOESNT WORK!
# This is what we would like to write, but is not supported
H H(22-3) * * *
Above expression means we want to build somewhen between 22 PM and 3 AM, this is a 5 hour period, so we could write:
# Assuming we're in GMT+2 we can just shift the timezone
# so 22-03 becomes 10-15 wich is 12 hours earlier so the
# timezone is GMT-10
TZ=Etc/GMT-10
H H(10-15) * * *
I found this workaround in the comments of JENKINS-18313
UPDATE:
There is currently a bug JENKINS-57702 and the timezone GMT-XX is not evaluated correctly. A workaround is to use a equivalent timezone, in this example the one for Hawaii:
TZ=US/Hawaii
H H(10-15) * * *

Resources