wr.s3.to_parquet returns "Both SchemaReference and Columns are populated, only one of them should be populated" - pandas

When writing a data frame to an existing table with glue schema using the following
wr.s3.to_parquet(
df=df,
path=path,
dataset=True,
partition_cols=["country", "year", "month", "day"],
mode="overwrite_partitions",
database=database,
table=table,
)
I get the following error
botocore.errorfactory.InvalidInputException: An error occurred (InvalidInputException) when calling the UpdateTable operation: Both SchemaReference and Columns are populated, only one of them should be populated.
But there seems to be no clear way to say, disable columns, when there is a schema defined on the table.

Related

Why do I get runtime error DBSQL_DBSL_LENGTH_ERROR?

I have the following code:
DATA: lt_matnr TYPE TABLE OF mara,
ls_matnr TYPE mara,
lv_werk TYPE werks_d VALUE 'WERK',
lt_stoc_int TYPE TABLE OF zmm_s_stock_list,
lt_stoc TYPE TABLE OF zsd_stock_list,
ls_stoc TYPE zsd_stock_list.
SELECT matnr
FROM mara
INTO CORRESPONDING FIELDS OF TABLE lt_matnr.
LOOP AT lt_matnr INTO ls_matnr.
CALL FUNCTION 'Z_MM_LIST_STOC_MATERIAL_WERKS'
EXPORTING
IP_MATNR = ls_matnr-matnr
IP_WERKS = lv_werk
IMPORTING
ET_STOCK_EXP = lt_stoc_int.
LOOP AT lt_stoc_int ASSIGNING FIELD-SYMBOL(<ls_stoc_int>).
MOVE-CORRESPONDING <ls_stoc_int> TO ls_stoc.
* + other data processing ...
APPEND ls_stoc TO lt_stoc.
ENDLOOP.
ENDLOOP.
INSERT zsd_stock_list FROM TABLE lt_stoc.
Everything works fine until the INSERT statement where I get the following short-dump:
Runtime error: DBSQL_DBSL_LENGTH_ERROR
Exception: CX_SY_OPEN_SQL_DB
Error analysis:
An exception has occurred which is explained in more detail below. The
exception, which is assigned to class 'CX_SY_OPEN_SQL_DB' was not caught an
therefore caused a runtime error. The reason for the exception is:
While accessing a database, the length of a field in ABAP does not
match the size of the corresponding database field.
This can happen for example if a string is bound to a database field
that is shorter than the current string.
It makes little sense because lt_stoc is TYPE TABLE OF zsd_stock_list, how can the field length not match ?

Failed to transfer data from GCS to Bigquery table

Need Help in DTS.
After creating a table "allorders" with autodetect schema, I created a data transfer service. But when I ran the DTS I'm getting an error. see Job below. quantity field type is for sure set to integer and all the data in the said field are whole numbers.
Job bqts_602c3b1a-0000-24db-ba34-30fd38139ad0 (table allorders) failed
with error INVALID_ARGUMENT: Error while reading data, error message:
Could not parse 'quantity' as INT64 for field quantity (position 14)
starting at location 0 with message 'Unable to parse'; JobID:
956421367065:bqts_602c3b1a-0000-24db-ba34-30fd38139ad0
When I recreated a table and set all fields to type string. It worked fine. see Job below
Job bqts_607cef13-0000-2791-8888-001a114b79a8 (table allorders)
completed successfully. Number of records: 56017, with errors: 0.
Try to find unparseable values in the table with all string fileds:
SELECT *
FROM dataset.table
WHERE SAFE_CAST(value AS INT64) IS NULL;

Dynamic INTO clause in OpenSQL?

I'm attempting to write a program that will grab the content from fields from a table both specified by the user on the selection screen.
For example, the user could specify the fields equnr, b_werk, b_lager from the table eqbs.
I've been able to accomplish this like so:
" Determine list of fields provided by user
DATA(lv_fields) = COND string(
WHEN p_key3 IS NOT INITIAL AND p_string IS NOT INITIAL THEN
|{ p_key1 }, { p_key2 }, { p_key3 }, { p_string }|
WHEN p_key2 IS NOT INITIAL AND p_string IS NOT INITIAL THEN
|{ p_key1 }, { p_key2 }, { p_string }|
WHEN p_key2 IS NOT INITIAL AND p_string IS NOT INITIAL THEN
|{ p_key1 }, { p_string }| ).
DATA: lv_field_tab TYPE TABLE OF line.
APPEND lv_fields TO lv_field_tab.
" Determine table specified by user and prepare for Open SQL query
DATA t_ref TYPE REF TO data.
FIELD-SYMBOLS: <t> TYPE any,
<comp> TYPE any.
CREATE DATA t_ref TYPE (p_table).
ASSIGN t_ref->* TO <t>.
ASSIGN COMPONENT lv_fields OF STRUCTURE <t> TO <comp>.
" Prepare result container
DATA: lt_zca_str_to_char TYPE TABLE OF zca_str_to_char,
ls_zca_str_to_char TYPE zca_str_to_char.
SELECT (lv_field_tab) FROM (p_table) INTO (#ls_zca_str_to_char-key1, #ls_zca_str_to_char-key2, #ls_zca_str_to_char-key3, #ls_zca_str_to_char-string).
APPEND ls_zca_str_to_char TO lt_zca_str_to_char.
ENDSELECT.
This will correctly populate lt_zca_str_to_char with data from the table specified by the user.
However, this implies that the user is always providing p_key1, p_key2, and p_key3. I could perform a different selection statement based on how many key fields the user provides, but what's the fun in that?
I set out to solve this like this:
DATA(lv_results) = COND string(
WHEN p_key3 IS NOT INITIAL AND p_string IS NOT INITIAL THEN
|(#ls_zca_str_to_char-key1, #ls_zca_str_to_char-key2, #ls_zca_str_to_char-key3, #ls_zca_str_to_char-string)|
WHEN p_key2 IS NOT INITIAL AND p_string IS NOT INITIAL THEN
|(#ls_zca_str_to_char-key1, #ls_zca_str_to_char-key2, #ls_zca_str_to_char-string)|
WHEN p_key2 IS NOT INITIAL AND p_string IS NOT INITIAL THEN
|(#ls_zca_str_to_char-key1, #ls_zca_str_to_char-string)| ).
SELECT (lv_field_tab) FROM (p_table) INTO (#lv_results).
APPEND ls_zca_str_to_char TO lt_zca_str_to_char.
ENDSELECT.
This will activate, and when I get to my Open SQL query (from a Z table, only filling out the first two of three possible key fields), the values are the following:
lv_field_tab = GUID, TEXT_ID, TEXT_DATA (Good)
p_table = ZCR_TRANS_TEXT (Good)
lv_results = (#ls_zca_str_to_char-key1, #ls_zca_str_to_char-key2, #ls_zca_str_to_char-string) (Good, 3 = 3!)
But, since I'm assuming the compiler is seeing (#lv_results) as one single variable, the program dumps with the following error:
The current ABAP program attempted to execute an Open SQL statement
containing a dynamic entry. The parser returned the following error:
"The field list and the INTO list must have the same number of
elements."
Is it possible for me to use the new Open SQL syntax to accomplish my dynamic INTO clause in harmony with my dynamic field list?
The brackets on the INTO do not do what you expect, from the ABAP help:
... INTO (#dobj1, #dobj2, ... )
Effect
If the results set consists of multiple columns or aggregate expressions specified explicitly in the SELECT list, a list of elementary data objects dobj1, dobj2, ... (in parentheses and separated by commas) can be specified after INTO.
In your case you only have one value in there so you can only select one column and the data will be passed in the variable LV_RESULT. Not what you are looking for. Since you want to fill the fields of an existing structure the INTO CORRESPONDING FIELDS OF construct will work here. And you can use TABLE to make your command more efficient as well. This leads to:
SELECT (lv_field_tab) FROM (p_table)
INTO CORRESPONDING FIELDS OF TABLE #lt_zca_str_to_char.
As said previously, you may use INTO CORRESPONDING FIELDS OF ..., but it's not mandatory, it's only for simplifying the code.
So, instead of using CORRESPONDING FIELDS, you may create a structure dynamically (RTTC) with its components corresponding to the columns in LV_FIELD_TAB, and you may then use:
SELECT (lv_field_tab) FROM (p_table) INTO #<structure> ... ENDSELECT.
But of course, as explained by Gert Beukema, you should better do only one SELECT, by creating an internal table dynamically with the same logic as for the structure above, and you may then use:
SELECT (lv_field_tab) FROM (p_table) INTO TABLE #<internal table> ...
Refer to the many examples in the web how to create data objects dynamically with RTTC.
Do not use a fields list for your INTO clause.
Try with
INTO CORRESPONDING FIELDS OF TABLE
must be a FIELD-SYMBOL type any table, and the rest of the logic is up to you (to put the proper information from your generic and almost-empty to your specific destination one).

How to avoid 'unique constraint' error message when creating a view

I have a normal View and iam getting the error message :
[Error] Execution (6: 83): ORA-00604: error occurred at recursive SQL level 1
ORA-00001: unique constraint (SYS.I_COL1) violated
But I don't get what I am doing wrong. It says the bacl.Description, batl.Description, bagl.description are violating the uniqueness constraint.
CREATE OR REPLACE FORCE VIEW CCI.VW_TA04_BAC_PAGE_4_2 as
SELECT
bac.id,
bac.code code,
bacl.DESCRIPTION,
bac.order_key,
bac.bat_id,
batl.description,
bac.bag_id,
bagl.description,
bac.weight_factor,
bac.display
FROM BART_CATEGORIES bac,
BART_CATEGORIES_LAE bacl,
BART_CATEGORY_GROUPS bag,
BART_CATEGORY_GROUPS_LAE bagl,
BART_CATEGORY_TYPES bat,
BART_CATEGORY_TYPES_LAE batl
WHERE bacl.lae_id = pkg_process.language
AND batl.lae_id = pkg_process.language
AND bagl.lae_id = pkg_process.language
AND (bac.bag_id = bag.id)
AND (bac.bat_id = bat.id)
AND (bacl.BAC_ID = bac.id)
AND (bagl.BAG_ID = bag.id)
AND (batl.BAT_ID = bat.id)
Thanks for any advice.
" It says the bacl.Description, batl.Description, bagl.description are violating the uniqueness constraint"
Your view has columns with the same name from three different tables. Column name must be unique in the view. So you need to alias those columns. For instance this would do the trick:
CREATE OR REPLACE FORCE VIEW CCI.VW_TA04_BAC_PAGE_4_2 as
SELECT
bac.id,
bac.code code,
bacl.DESCRIPTION as bac_description,
bac.order_key,
bac.bat_id,
batl.description as bat_description,
bac.bag_id,
bagl.description as bag_description,
bac.weight_factor,
bac.display
" i tought writing "bacl" in front or would be enough."
We need both. The table alias tells the SQL engine which table provides the referenced value but it is not part of the column name.

Unrelated Column reference with filter syntax error

Im using SSAS Tabular. Trying to insert a column which gets data(OrgNumber) from an unrelated table called DimCustomer.
DAX-Syntax:
=Calculate(Values('DimCustomer'[OrgNum]),FILTER('DimCustomer','DimCustomer'[CustomerNr]='FactTransactions'[CustomerNr])))
Throws back error msg:
The syntax for 'FILTER' is incorrect.
The calculated column 'FactTransactions[CalculatedColumn1]' contains a syntax error. Provide a valid formula.
Try this:
=LOOKUPVALUE('DimCustomer'[OrgNum], 'DimCustomer'[CustomerNr], 'FactTransactions'[CustomerNr])
This assumes it is a calculated column on FactTransactions
I laid out your code like the below and it seems you have an extra bracket:
=Calculate
(
Values('DimCustomer'[OrgNum]),
FILTER
(
'DimCustomer',
'DimCustomer'[CustomerNr]='FactTransactions'[CustomerNr]
)
)
)