Not able to write beamSql data to BigQuery - apache-beam

I'm trying to write beamSql data to BigQuery as shown below :
final_out1.apply(BigQueryIO.<TableRow>Write
.named("Write")
.to("my-project:data_id1.tables_test")
.withSchema(schema)
.withWriteDisposition(BigQueryIO.Write.WriteDisposition.WRITE_TRUNCATE))
.withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_IF_NEEDED));
I'm getting error on named(), the error :
The method named(String) is undefined for the type BigQueryIO.Write
Any idea what this means ?
EDIT
The format function that I defined :
final_out1.apply(BigQueryIO.<TableRow>write()
.withSchema(schema)
.to("beta-194409:data_id1.tables_test"));
/* .withFormatFunction(fin -> new TableRow().
set("SalesComponent", fin.getSalesComponent()).
set("DuetoValue", fin.getDuetoValue()).
set("ModelIteration", fin.getMo//delIteration())) */
//.withWriteDisposition(BigQueryIO.Write.WriteDisposition.WRITE_TRUNCATE).withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_IF_NEEDED));

There is no such method named() for class BigQueryIO.Write so this error makes sense.
You can specify a transform name as the first parameter of the apply() method.
final_out1.apply("Write", BigQueryIO.<TableRow>.write()
.to("my-project:data_id1.tables_test")
.withSchema(schema)
.withWriteDisposition(BigQueryIO.Write.WriteDisposition.WRITE_TRUNCATE))
.withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_IF_NEEDED));
Note: Use BigQueryIO.write() instead of BigQueryIO.Write.

Related

how to pass the arguments to the function given below, I am using a DS applied on case class. apparently the function is expecting seq[case class]

AddressRawData and AddressData both are case class
I am getting data in the addressDF
Now I have to parse the data to the function addressParser, Unfortunately the parser is expecting Seq[AddressData] and returning Seq[AddressData]
Keeping the function "addressParser" untouched how do I pass my addressDS to the function "addressParser" ?
I have attached my code on the below url
git#github.com:chameleonlabs2021/assessment.git

Symfony Form - Value Object, DataMappers and EventSubscriber

I am having trouble to dynamically modify field in my form using DataMapper and EventSubscriber.
Here is my form:
A select field
A field which will be modified by the select field above.
I am using an EventSubscriber to dynamically modify my form using AJAX.
And a DataMapper to map my Value Object to the form and vice-versa.
So when i do that:
$moneyForm = $this->createForm(MoneyType::class);
Everything is working. But when i pass my Value Object as data class:
$money = new Money(199, 'USD');
$moneyForm = $this->createForm(MoneyType::class, $money);
I got an error here:
public function mapDataToForms($viewData, $forms)
{
$forms = iterator_to_array($forms);
$forms['money']->setData($viewData ? $viewData->money() : 0);
$forms['currency']->setData($viewData ? $viewData->currency() : 'USD');
}
This error says that: Notice: Undefined index:.
It seems like the form has been replaced by a new one and i don't understand it.
I don't know why when i use a data mapper alone, or event subscriber alone everything is working.
But when i try to mix, both of them i got this error.
Does anyone have a clue of what's going on here?
Thank you

Vue Conditional Class Binding

I am trying to dynamically render class based off actionTypeCreate. This is a method that simply returns a boolean value based off the prop actionType that is passed. I am triggering this method on the mounted hook and confirmed it is returning properly.
Now I am trying to return the class value of 'col-md-4' if actionTypeCreate. If not actionTypeCreate I want to return the class 'col-md-6'.
This is what I have but it is not working:
:class="{toggleActionType : 'col-md-4' ? 'col-md-6'}"
I tried to reference this existing question, but I did not get it.
You can do it as follows:
:class="{'col-md-4' : toggleActionType , 'col-md-6' : !toggleActionType }"
According to the Vue documentation itself you can do it in two ways. First, you can use Array Syntax and this is broadly used to apply a list of classes.
Array Syntax
:class="[toggleActionType ? 'col-md-4' : 'col-md-6']"
Or you can do it as normal by Object Syntax but it does not accept ternary operations, so you have to do it this way:
Object Syntax
:class="{'col-md-4' : toggleActionType , 'col-md-6' : !toggleActionType}"
Try this:
:class="[toggleActionType : 'col-md-4' ? 'col-md-6']"

How to pass parameters to a Progress program using database field dynamic-based rules?

I have in my database a set of records that concentrates information about my .W's, e.g. window name, parent directory, file name, procedure type (for internal treatments purposes), used to build my main menu. With this data I'm developing a new start procedure for the ERP that I maintain and using the opportunity in order to rewrite some really outdated functions and programs and implement new functionalities. Until now, I hadn't any problems but when I started to develop the .P procedure which will check the database register of a program that was called from the menu of this new start procedure - to check if it needs to receive fixed parameters to be run and its data types - I found a problem that I can't figure out a solution.
In this table, I have stored in one of the fields the parameters needed by the program, each with his correspondent data type. The problem is on how to pass different data types to procedures based only on the stored data. I tried to pre-convert data using a CASE clause and an include to check the parameter field for correct parameter sending but the include doesn't work as I've expected.
My database field is stored as this:
Description | DATATYPE | Content
I've declared some variables and converted properly the stored data into their correct datatype vars.
DEF VAR c-param-exec AS CHAR NO-UNDO EXTENT 9 INIT ?.
DEF VAR i-param-exec AS INT NO-UNDO EXTENT 9 INIT ?.
DEF VAR de-param-exec AS DEC NO-UNDO EXTENT 9 INIT ?.
DEF VAR da-param-exec AS DATE NO-UNDO EXTENT 9 INIT ?.
DEF VAR l-param-exec AS LOG NO-UNDO EXTENT 9 INIT ?.
DEF VAR i-count AS INT NO-UNDO.
blk-count:
DO i-count = 0 TO 8:
IF TRIM(programa.parametro[i-count]) = '' THEN
LEAVE blk-count.
i-count = i-count + 1.
CASE ENTRY(2,programa.parametro[i-count],CHR(1)):
WHEN 'CHARACTER' THEN
c-param-exec[i-count] = ENTRY(3,programa.parametro[i-count],CHR(1)).
WHEN 'INTEGER' THEN
i-param-exec[i-count] = INT(ENTRY(3,programa.parametro[i-count],CHR(1))).
WHEN 'DECIMAL' THEN
de-param-exec[i-count] = DEC(ENTRY(3,programa.parametro[i-count],CHR(1))).
WHEN 'DATE' THEN
da-param-exec[i-count] = DATE(ENTRY(3,programa.parametro[i-count],CHR(1))).
WHEN 'LOGICAL' THEN
l-param-exec[i-count] = (ENTRY(3,programa.parametro[i-count],CHR(1)) = 'yes').
OTHERWISE
c-param-exec[i-count] = ENTRY(3,programa.parametro[i-count],CHR(1)).
END CASE.
END.
Then I tried to run the program using an include to pass parameters (in this example, the program have 3 INPUT parameters).
RUN VALUE(c-prog-exec) ({util\abrePrograma.i 1},
{util\abrePrograma.i 2},
{util\abrePrograma.i 3}).
Here is my abrePrograma.i
/* abrePrograma.i */
(IF ENTRY(2,programa.parametro[{1}],CHR(1)) = 'CHARACTER' THEN c-param-exec[{1}] ELSE
IF ENTRY(2,programa.parametro[{1}],CHR(1)) = 'INTEGER' THEN i-param-exec[{1}] ELSE
IF ENTRY(2,programa.parametro[{1}],CHR(1)) = 'DECIMAL' THEN de-param-exec[{1}] ELSE
IF ENTRY(2,programa.parametro[{1}],CHR(1)) = 'DATE' THEN da-param-exec[{1}] ELSE
IF ENTRY(2,programa.parametro[{1}],CHR(1)) = 'LOGICAL' THEN l-param-exec[{1}] ELSE
c-param-exec[{1}])
If I suppress the 2nd, 3rd, 4th and 5th IF's from the include or use only one data type in all IF's (e.g. only CHAR, only DATE, etc.) the program works properly and executes like a charm but I need to call some old programs, which expects different datatypes in its INPUT parameters and using the programs as described OpenEdge doesn't compile the caller, triggering the error number 223.
---------------------------
Erro (Press HELP to view stack trace)
---------------------------
** Tipos de dados imcompativeis em expressao ou atribuicao. (223)
** Nao entendi a linha 86. (196)
---------------------------
OK Ajuda
---------------------------
Can anyone help me with this ?
Thanks in advance.
Looks as if you're trying to use variable parameter definitions.
Have a look at the "create call" statement in the ABL reference.
http://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvref/call-object-handle.html#wwconnect_header
Sample from the documentation
DEFINE VARIABLE hCall AS HANDLE NO-UNDO.
CREATE CALL hCall.
/* Invoke hello.p non-persistently */
hCall:CALL-NAME = "hello.p".
/* Sets CALL-TYPE to the default */
hCall:CALL-TYPE = PROCEDURE-CALL-TYPE
hCall:NUM-PARAMETERS = 1.
hCall:SET-PARAMETER(1, "CHARACTER", "INPUT", "HELLO WORLD").
hCall:INVOKE.
/* Clean up */
DELETE OBJECT hCall.
The best way to get to the bottom of those kind of preprocessor related issues is to do a compile with preprocess listing followed by a syntax check on the preprocessed file. Once you know where the error is in the resulting preprocessed file you have to find out which include / define caused the code that won't compile .
In procedure editor
compile source.w preprocess source.pp.
Open source.pp in the procedure editor and do syntax check
look at original source to find include or preprocessor construct that resulted in the code that does not compile.
Okay, I am getting a little bit lost (often happens to me with lots of preprocessors) but am I missing that on the way in and out of the database fields you are storing values as characters, right? So when storing a parameter in the database you have to convert it to Char and on the way out of the database you have convert it back to its correct data-type. To not do it one way or the other would cause a type mismatch.
Also, just thinking out loud (without thinking it all the way through) wonder if using OOABL (Object Oriented ABL) depending on if you Release has it available wouldn't make it easier by defining signatures for the different datatypes and then depending on which type of input or output parameter you call it with, it will use the correct signature and correct conversion method.
Something like:
METHOD PUBLIC VOID storeParam(input cParam as char ):
dbfield = cParam.
RETURN.
END METHOD.
METHOD PUBLIC VOID storeParam(input iParam as int ):
dbfield = string(iParam).
RETURN.
END METHOD.
METHOD PUBLIC VOID storeParam(input dParam as date ):
dbfield = string(dParam).
RETURN.
END METHOD.
just a thought.

Populating the list in g.select

I need to programmatically load a list.
Instead of:
<g:select
name="cars"
from="${Car.list()}"
value="${person?.cars*.id}"
optionKey="id"
multiple="true" />
I would like to do it this because, the list is not always coming from the same source
g.select(name : searchfield.fieldName,
class : "fillWidth searchfield",
multiple : "true",
from : ${ searchfield.fieldFrom },
optionKey : searchfield.fieldKey,
optionValue : searchfield.fieldValue)
The from does not load. with the list, I get an error message:
No signature of method: sample.SearchTagLib.$() is applicable for argument types: (sample.SearchTagLib$_getSelectField_closure5) values: [sample.SearchTagLib$_getSelectField_closure5#1187b50] Possible solutions: is(java.lang.Object), any(), use([Ljava.lang.Object;), any(groovy.lang.Closure), wait(), grep()
You don't need the ${} in the from option
g.select(name : searchfield.fieldName,
class : "fillWidth searchfield",
multiple : "true",
from : searchfield.fieldFrom,
optionKey : searchfield.fieldKey,
optionValue : searchfield.fieldValue)
In Groovy code ${} is a way to put Groovy expressions inside double quoted GStrings, if you're not in a GString you can just use the expression directly without wrapping it in ${}.
Edit from your comment
The fieldFrom at this point is a string which would get its value from a database. So the value in the DB is "Car.list()" which in the prototype I need to convert to a bound able or execute-able line of code.
It's not generally recommended to allow your app to execute arbitrary snippets of Groovy code provided by users (for obvious security reasons). As long as the code snippets come from a secure source such as a trusted admin user then fair enough, it is possible using GroovyShell
def from = new GroovyShell().evaluate(searchfield.fieldFrom)
but this is likely to be rather inefficient, creating a new classloader and parsing and compiling a whole Groovy script class every time. If the fieldFrom values are intended to always be pulling something from the database (i.e. they'll always be something like Car.list() or Vehicle.findAllByNumberOfWheelsGreaterThan(2), rather than arbitrary Groovy like [1,2,3]) then it might be better to store HQL expressions in fieldFrom and run them using executeQuery
def from = AnyDomainClass.executeQuery(searchfield.fieldFrom)
(executeQuery is a static GORM method, you need to call it on a specific domain class but it can return results of any type). The HQL equivalent of Car.list() would be "from Car", the equivalent of Vehicle.findAllByNumberOfWheelsGreaterThan(2) would be "from Vehicle where numberOfWheels > 2", etc.
I think you need to use strings as the attribute name:
g.select('name' : searchfield.fieldName,
'class' : "fillWidth searchfield",
'multiple' : "true",
'from' : ${ searchfield.fieldFrom },
'optionKey' : searchfield.fieldKey,
'optionValue' : searchfield.fieldValue)