Elassandra not indexing UDT - elassandra

This error occurs with elassandra 5.5.018 and 6.2.3.2.
I have this table structure:
CREATE TYPE applicationinfo (
industry text,
area_of_application text,
product_group text,
sic_code text,
conveyed_product text,
flowability text,
viscosity text,
solids_content text,
size_of_solids text,
concentration text,
composition text,
specific_gravity text,
ph_value text,
product_temperature_min int,
product_temperature_max int
);
CREATE TABLE deviceinfo (
id text,
"applicationinfo" applicationinfo
PRIMARY KEY (id)
);
In my test-case there are some (about 100 entries inserted).
When i try to create an elastic index for the deviceinfo table it fails with this exception:
2018-07-04 14:49:56,894 ERROR [SecondaryIndexManagement:3] CassandraDaemon.java:231 uncaughtException Exception in thread Thread[SecondaryIndexManagement:3,5,main]
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.nio.BufferUnderflowException
at org.apache.cassandra.utils.Throwables.maybeFail(Throwables.java:51)
at org.apache.cassandra.utils.FBUtilities.waitOnFutures(FBUtilities.java:373)
at org.apache.cassandra.index.SecondaryIndexManager.buildIndexesBlocking(SecondaryIndexManager.java:392)
at org.apache.cassandra.index.SecondaryIndexManager.buildIndexesBlocking(SecondaryIndexManager.java:367)
at org.apache.cassandra.index.SecondaryIndexManager.buildIndexBlocking(SecondaryIndexManager.java:288)
at org.elassandra.index.ElasticSecondaryIndex.lambda$getInitializationTask$5(ElasticSecondaryIndex.java:2266)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.cassandra.concurrent.NamedThreadFactory.lambda$threadLocalDeallocator$0(NamedThreadFactory.java:81)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.concurrent.ExecutionException: java.nio.BufferUnderflowException
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.apache.cassandra.utils.FBUtilities.waitOnFutures(FBUtilities.java:366)
... 9 common frames omitted
What am I doing wrong?

Answering own question. The issue has been resolved here:
https://github.com/strapdata/elassandra/issues/210
The solution is to freeze the udt fields:
CREATE TABLE deviceinfo (
id text,
"applicationinfo" frozen<applicationinfo>,
baseinfo frozen<baseinfo>,
"product" frozen<product>,
"specification" frozen<specification>,
"technicaldata" frozen<technicaldata>,
"customer" frozen<customer>,
PRIMARY KEY (id)
);

Related

Power BI(DAX) | Getting rows with the same value

I need some help with getting a final status per each ID. The table is sorted by time, and IDs are composed of random alphabets and numbers. Currently a final status is in a string format like below. I created a look up table for each status, converting each status to a numerical value as I wished to be prioritized. What I want is, if operations for an ID has at least one "Complete", I want the table to say "yes", and otherwise(no Complete at all) "no". For example of ID "K304R" below, it operated three times with Status of "Completed", "Error", and "Canceled", and thus the result I want would be a "yes".
My intuition was 1) ALLEXCEPT original table with ID and Status, 2) somehow get rows with the same ID(ex "K304R"), 3) somehow get Status for each rows of "K304R", 4) somehow connect Status back to the look up table, 4) get Max value for statuses, 5) return "yes" if the max value is 100, and otherwise "no".
Any help would be really appreciated. Thanks ahead!
OriginalTable
Time
ID
Status
2022/10/4 10:47AM
1ZT56
Error
2022/10/4 9:47AM
K304R
Completed
2022/10/4 7:47AM
K304R
Canceled
2022/10/3 10:47PM
1ZT56
Completed
2022/10/3 7:47AM
PQ534
Canceled
2022/10/3 4:47AM
12PT3
Error
2022/10/2 10:40PM
12PT3
Error
2022/10/2 7:47PM
1ZT56
Canceled
2022/10/1 10:47AM
U73RL
Completed
LookupTable
Status
StatusVal
Completed
100
Canceled
0
Error
0
Result I want
Time
ID
Status
FinalStatus
2022/10/4 10:47AM
1ZT56
Error
yes
2022/10/4 9:47AM
K304R
Completed
yes
2022/10/4 7:47AM
K304R
Canceled
yes
2022/10/3 10:47PM
1ZT56
Completed
yes
2022/10/3 7:47AM
PQ534
Canceled
no
2022/10/3 4:47AM
12PT3
Error
no
2022/10/2 10:40PM
12PT3
Error
no
2022/10/2 7:47PM
1ZT56
Canceled
yes
2022/10/1 10:47AM
U73RL
Completed
yes
This calculated column works:
FinalStatus =
if(
CALCULATE(
COUNTROWS(OriginalTable),
FILTER(OriginalTable,
OriginalTable[ID] = EARLIER(OriginalTable[ID]) &&
OriginalTable[Status]="Completed"))>0,
"Yes","No")
The idea is to filter the table for rows where the ID matches the ID in question, then filter for rows where status is "Completed", and then count the remaining rows.

Oracle Window function not working in SnowFlake

i am working on Oracle to Snowflake migration.
while migrating oracle window functions to snowflake getting below error, could you let me know, alternate way for oracle function in snowflake.
SELECT
COL1,
COL2, ...,
SUM(SUM(TAB1.COL1)) OVER (PARTITION BY
TAB1.COL2,
TAB1.COL3,
TAB1.COL4,
TAB1.COL5,
TAB1.COL6,
TAB1.COL7,
TAB1.COL8,
TAB1.COL9,
TAB1.COL10,
ORDER BY MAX(CALENDAR_TAB.DATE_COLUMN) RANGE BETWEEN INTERVAL '21' DAY PRECEDING AND CURRENT ROW)/4 AS COLMN
FROM TAB1,CALENDAR_TAB
JOIN
GROUP BYCOL1,
COL2, ...
Below is the error message:
QL Error [1003] [42000]: SQL compilation error:
syntax error line 75 at position 60 unexpected 'INTERVAL'.
syntax error line 75 at position 78 unexpected 'PRECEDING'.
Per the documentation for Snowflake, here is the syntax:
https://docs.snowflake.com/en/sql-reference/functions-analytic.html#window-syntax-and-usage
slidingFrame ::=
{
ROWS BETWEEN <N> { PRECEDING | FOLLOWING } AND <N> { PRECEDING | FOLLOWING }
| ROWS BETWEEN UNBOUNDED PRECEDING AND <N> { PRECEDING | FOLLOWING }
| ROWS BETWEEN <N> { PRECEDING | FOLLOWING } AND UNBOUNDED FOLLOWING
}
It might not like the INTERVAL and the quoted number.
The Window frame document is a good place to start.
If I read the Oracle syntax correctly, the window frame your are using for the MAX is value based aka (interval '21' day) which Snowflake does not support, it only supports N rows based logic. If you have 1 row per day, and always 1 row, then you can use the row count logic, but otherwise this is not supported.
Which means you to join back to your own data tables and apply the prior time filter on the join.

Regular Expression for Splunk - extract between two phrases across multiple lines.

I am trying to extract log data in splunk and my current usecase is more complicated that what the "regex builder" will allow for. Consider the below example, I would like to extract all the text between two phrases. I can get small, one line samples to work between two words, but I've not been able to get this to work at all. The separate line breaks are not helping either.
Thanks for any help you can provide!
Phrase1: Stuff.Applications.Business.StuffApi.Common.Exceptions.ValidationException:
Phrase2:
at Stuff.Applications.Business.StuffApi.Web.Controllers.Stuff.Things
Example Data:
02/26/2018 02:17:08 PM
LogName=Stuff
SourceName=StuffApi
EventCode=400
EventType=2
Type=Error
ComputerName=Stuff.things.Words
TaskCategory=%1
OpCode=Info
RecordNumber=3129
Keywords=Classic
Message=2018-02-26 14:17:08,767 [63] ERROR Things [(null)] - Something Number: ; Something Number: 9999999999 ; Source Application: ABCD ; Error Type: Validation ; Response Status Code: 400
Stuff.Applications.Business.StuffApi.Common.Exceptions.ValidationException: Validation Errors: Error:ErrorInfo.Error cannot be greater than the current date: 2/26/2018 12:00:00 AM, Incoming Value:2/27/2018 12:00:00 AM;
at Stuff.Applications.Business.StuffApi.Web.Controllers.Stuff.Things(SomeRequest request) in f:\Builds\348\Policy Systems\V.12_Release.Applications.Business.Things\src\src\Web\Controllers\Stuff.cs:line 288
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Try this regex
Stuff\.Applications\.Business\.StuffApi\.Common\.Exceptions\.ValidationException:(?<text>[\s\S]+)at Stuff\.Applications\.Business\.StuffApi\.Web\.Controllers\.Stuff\.Things

System.Data.SqlClient.SqlException{"Incorrect syntax near the keyword 'by'."}

{
STDB.Open();
string query = $"INSERT INTO [dbo].[Inbound](Trailer#, Shipper#,
Seal#, Recieved By, Recieving Shift, Carrier, Supplier, Vendor,
Contents, Location, Comments) VALUES ('{textBox1.Text}',
'{textBox2.Text}','{textBox3.Text}', '{comboBox5.Text}',
'{comboBox1.Text}','{comboBox6.Text}', '{textBox4.Text}',
'{textBox5.Text}',' {comboBox2.Text}', '{comboBox3.Text}',
'{textBox6.Text}')";
SqlDataAdapter SDA = new SqlDataAdapter(query, STDB);
SDA.SelectCommand.ExecuteNonQuery();
STDB.Close();
MessageBox.Show("Done");
}
(This is a filler text from the editor, because this post was originally posted as just only the code but without the code format, I've edited the code to make it at least a bit more readable for the others)
You do not want the , after the by. You want the command after the first field in the by. If a column has a space in the name surround the field name is [ ]
{ STDB.Open(); string query = $"INSERT INTO [dbo].[Inbound](Trailer#, Shipper#, Seal#, Recieved By [Recieving Shift], Carrier, Supplier, Vendor, Contents, Location, Comments)

If and REGEXTRACT

I have a text (see below) where
I would like to extract the date only for the specific status, when the date appears after "New on Date".
I want the formula to answer: if the status is "New" then extract the "date".
I tried this: =If(A2 = "New",REGEXEXTRACT(A2,"(\d{1,}?\/\d{1,}?\/\d{4})"),)
I also tried the same by adding Find and Search but still unsuccessful.
I know that this part of the formula works: REGEXEXTRACT(A2,"(\d{1,}?\/\d{1,}?\/\d{4})")
But I do not manage to find the other part: Would anyone have a guess?
Contract Rejected/Contract Withdrew on Date: 11/11/2016 6:23:33 AM and Modified by: Eletttt|| Offer Negotiation on Date: 6/2/2016 5:36:04 AM and Modified by: Dexx|| HR Screening on Date: 4/14/2016 2:30:57 AM and Modified by: Dexxx|| New on Date: 4/14/2016 2:24:58 AM and Modified by: Dexxx|| Contract sent on Date: 6/7/2016 11:03:58 AM and Modified by: Chrisyyy|| Pending Contract Approval on Date: 6/7/2016 4:56:55 AM and Modified by: Debxxx|| HM Interview on Date: 5/10/2016 12:40:30 AM and Modified by: Debxxx
If you need to extract the date after New on Date, you need to add this text to the pattern and keep the capturing group where it is now:
=REGEXEXTRACT(A2, "New on Date:\s*(\d{1,2}/\d{1,2}/\d{4})")
See the screenshot (with the data inside B29 cell):
See the regex demo.
Here is a simpler one for you:
=REGEXEXTRACT(A1,"New on Date:\s(\d\S+)")