Hql case statement - case

|keyid | test
|:---- |:----
|161289462| valid
|50578283 | valid
|UGM49O3 | valid
I am using below query but still getting wrong results.
> Select keyid,CASE WHEN keyid like '^[A-Za-z]*%' THEN 'invalid' else
> 'valid' end as test
from table
I am expecting below
|keyid | test
|:---- |:----
|161289462| valid
|50578283 | valid
|UGM49O3 | Invalid

Related

Why SHOW ERRORS or SHOW WARNINGS lists only the very last error/warning?

I am using the SHOW ERRORS and SHOW WARNIGS statments (on MariaDB 10.10.2) and regardless of the max_error_count is in its default 64 value, the statements above only list the very last error/warning.
Question
How can I list all the last recent errors/warning according the max_error_count variable?
The SQL statement SHOW ERRORS/WARNINGS only returns error or warnings for the last statement which failed or produced a warning. They can be retrieved until another statement produced an error/warning.
If a statement produced more than one error/warnings, then the SHOW ERRORS/WARNINGS return up to max_error warnings.
Example:
delimiter $$
CREATE PROCEDURE p1() BEGIN DROP TABLE whichdoesnotexist; END $$
CREATE PROCEDURE p2() BEGIN CALL p1(); END $$
CREATE PROCEDURE p3() BEGIN CALL p2(); END $$
delimiter ;
SET ##max_error_count=2;
CALL p3();
SHOW WARNIINGS;
+-------+------+----------------------------------------+
| Level | Code | Message |
+-------+------+----------------------------------------+
| Error | 1051 | Unknown table 'test.whichdoesnotexist' |
| Note | 4094 | At line 2 in test.p1 |
+-------+------+----------------------------------------+
SET ##max_error_count=4;
CALL p3();
SHOW WARNINGS;
+-------+------+----------------------------------------+
| Level | Code | Message |
+-------+------+----------------------------------------+
| Error | 1051 | Unknown table 'test.whichdoesnotexist' |
| Note | 4094 | At line 2 in test.p1 |
| Note | 4094 | At line 2 in test.p2 |
| Note | 4094 | At line 2 in test.p3 |
+-------+------+----------------------------------------+
# This will not clear warning/errors
SELECT "1","2","3";
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
SHOW WARNINGS;
+-------+------+----------------------------------------+
| Level | Code | Message |
+-------+------+----------------------------------------+
| Error | 1051 | Unknown table 'test.whichdoesnotexist' |
| Note | 4094 | At line 2 in test.p1 |
| Note | 4094 | At line 2 in test.p2 |
| Note | 4094 | At line 2 in test.p3 |
+-------+------+----------------------------------------+
SHOW ERRORS and SHOW WARNINGS only show errors/warnings from the most recent statement in the same session. They will never show anything from previous statements or other sessions. max_error_count will reduce the number shown, but never cause anything else to be shown.
MariaDB [test]> select version();
+-----------------------------------------+
| version() |
+-----------------------------------------+
| 10.10.2-MariaDB-1:10.10.2+maria~ubu2204 |
+-----------------------------------------+
1 row in set (0.001 sec)
MariaDB [test]> select date(d) from (select '' d union all select 20220229) d;
+---------+
| date(d) |
+---------+
| NULL |
| NULL |
+---------+
2 rows in set, 2 warnings (0.002 sec)
MariaDB [test]> show warnings;
+---------+------+--------------------------------------+
| Level | Code | Message |
+---------+------+--------------------------------------+
| Warning | 1292 | Incorrect datetime value: '' |
| Warning | 1292 | Incorrect datetime value: '20220229' |
+---------+------+--------------------------------------+
2 rows in set (0.000 sec)
MariaDB [test]> set session max_error_count=1;
Query OK, 0 rows affected (0.001 sec)
MariaDB [test]> select date(d) from (select '' d union all select 20220229) d;
+---------+
| date(d) |
+---------+
| NULL |
| NULL |
+---------+
2 rows in set, 2 warnings (0.001 sec)
MariaDB [test]> show warnings;
+---------+------+------------------------------+
| Level | Code | Message |
+---------+------+------------------------------+
| Warning | 1292 | Incorrect datetime value: '' |
+---------+------+------------------------------+
1 row in set (0.000 sec)

combine multiple jq commands into one?

I use the following command to extract data from a json file. Suppose that I just keep the first match if there is a match. (If there is no match, an error should be printed.)
.[] | select(.[1] | objects."/Type".N == "/Catalog") | .[1]."/Dests"
Let's say the output is 16876. Then, I use the following jq code to extract the data.
.[] | select(.[0] == 16876) | .[1] | to_entries[] | [.key, .value[0], .value[2].F, .value[3].F] | #tsv
This involves multiple passes of the input json data. Can the two jq commands be combined into one, so that one pass of the input json data is sufficient?
Use as $dests to bind the results of your first query branch to the name $dests, and then refer back to those results in the second branch within a single copy of jq.
(.[] | select(.[1] | objects."/Type".N == "/Catalog") | .[1]."/Dests") as $dests
| .[] | select(.[0] == $dests) | .[1] | to_entries[] | [.key, .value[0], .value[2].F, .value[3].F] | #tsv

How to convert the jsonb datatype to other datatype in psql for amazon quicksight

My Psql database has a table which has jsonb as type for some columns, when i tried to upload these tables in amazon quicksight for some analysis purpose, am getting an error says unsupported datatype and the columns are getting skipped in amazom Quicksight.
Please help me to convert these into some supported type in amazon Quicksight.
Column | Type | Collation | Nullable | Default
---------------+-----------------------------+-----------+----------+-----------------------------------------------
id | bigint | | not null | nextval('solera_progresses_id_seq'::regclass)
milestones | jsonb | | |
reference_id | character varying | | |
response_code | integer | | |
activity | jsonb | | |
response | jsonb | | |
user_id | bigint | | |
You can use custom SQL to convert the data to the supported type before loading to Quicksight.
For instance, if your jsonb column contains objects like {"name": "John"}, you can create a column name in Quicksight using the query:
SELECT column_name->'name' AS name
FROM table_name

StartTag: invalid element name Error: 1: StartTag: invalid element name

I have an xml which I am trying to parse using xmlParse in R. I have a number of xml's which are very similar to what I am trying below and I have no issues, however when trying the exact same process using one of my xml's, I get the below error message.
a = "productlist1374.xml"
b = xmlParse(a)
StartTag: invalid element name
Error: 1: StartTag: invalid element name
Only certain characters are permitted in XML names by the W3C XML BNF for component names:
Name ::= NameStartChar (NameChar)*
NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] |
[#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] |
[#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
[#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] |
[#x10000-#xEFFFF]
NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] |
[#x203F-#x2040]
You've not posted your XML, but clearly one or more of your start tags uses a character or characters that are not allowed.

Drools - Decision tables without constraints

I need to do a rule with no constraints in a decision table.
i.e.:
rule ...
when
$p : Person()
then
$p.setCity("none");
end
I tried these:
| 1 | RuleTable example |
| 2 | CONDITION | ACTION |
| 3 | p:Person() | |
| 4 | name | p.setCity("$param"); |
| 5 | description | config person |
| 6 | | none |
But when I run application throws this exception:
person cannot be resolved
Exception in thread "main" java.lang.IllegalArgumentException: No se puede parsear base de conocimiento.
Probably it fails because you have no real condition in your table.
Try putting $param == $param as condition
Use condition like as shown in picture. It will generate DRL as:
rule "XYZ"
when
doc:Document()
then
doc.setX("Y");
end

Resources