Cannot update datatype on temporal table to NOT NULL - temporal-tables

I need to change a column datatype to NOT NULL on a Temporal (system versioned) table. The attached history table has null values in the column that need to go away before it will let me make the change. I attempted to turn off system_versioning for the temporal table and make my update directly to the history table. I was not able to turn off system_versioning as it is referenced by a view.

Related

PowerBI: Comparing a filterd table against a variable string is returning an empty table

Please see the code below for a Power BI table in DAX:
TABLE1 =
VAR ParticipantOneParticipantId =
SELECTEDVALUE(
ParticipantOneDetails[ParticipantId]
)
RETURN
FILTER(
ParticipantOneMeetings,
ParticipantOneMeetings[ParticipantId] = ParticipantOneParticipantId
)
I am fetching a value for ParticipantId from a sliced table called ParticipantOneDetails and setting ParticipantOneParticipantId to it.
In the next step I am trying to filter the table ParticipantOneMeetings based on its column ParticipantId comparing it against ParticipantOneParticipantId.
The problem is that the resulting table is coming out empty even though I know that ParticipantOneParticipantId must have a value and the ParticipantOneMeetings table also has values. I verified by comparing against a hard-coded string.
Can you please point out what I am doing wrong? Is comparing this way not legal?
The problem lies in the process you are trying. A calculated/custom tables and columns are static. They always refresh when the data set is refreshed. They do not interact dynamically with the slicer value. So it is impossible to get data from a slicer dynamically for a Custom Table generation.
Now, your requirement of creating a new table based on slicer value is not completely clear to me. As what you are trying, is a simple filtered output of your table "ParticipantOneMeetings" after applying the Slicer. If you have relation between your 2 tables using column "ParticipantId", change in Slicer will automatically filter out values in ParticipantOneMeetings table. Why you wants to hold this same filtered values in a new Custom table is really a mater here to know for finding appropriate solution for you.
Turns out I needed to add the following measure to the table output:
MeetingsAttendedByBothParticipants =
countrows(
INTERSECT(
VALUES(ParticipantOneMeetings[Name]),
VALUES(ParticipantTwoMeetings[Name])
)
)
The above provides an intersection on output of two sliced meeting tables. This results in a list of meetings that both persons attend.

Default date aggregation for Excel

What is the default behavior of adding a date, time, or datetime into an Excel pivot row/column? I have seen it sometimes add it as the "raw value", sometimes it will add it as a Year > Query > Value, and other times (?) perhaps in between. For example:
When does Excel add it without aggregating it, and when does Excel aggregate it? Does it have to do with value cardinality, date range, or something else?
First, every entry in the column has to be a date/time or you won't be able to group them. In that case, obviously, the default would be not grouped.
Assuming everything is groupable, the default is no grouping. Each date will show individually.
The exception is if a pivot cache already exists. In that case it will group based on what the pivot cache says - the last way that field was grouped. This happens when you have more than one pivot table on the same data. The first pivot table creates the cache and all subsequent pivot tables use that existing cache.
In a new workbook (2010), I add a date field to the Row Labels and they are initially ungrouped by default.
I group them by month
Now I go back to the original data and make a new pivot table. I add the date field to the Column Labels.
Because it uses the same cache, it automatically has them grouped the same way. Finally, I go back to the source data and replace one of the dates with a string. If I create another pivot table, it will look like the others. But when I refresh it ungroups them because I have a non-date in there.
And if I try to Group now, it says "Cannot group that selection"
That's why it works the way it does - shared pivot cache. There are ways you can give each pivot table it's own cache but that uses more memory. However, if you want to group the same data differently, that's what you have to do.

Cassandra Altering the table

I have a table in Cassandra say employee(id, email, role, name, password) with only id as my primary key.
I want to ...
1. Add another column (manager_id) in with a default value in it
I know that I can add a column in the table but there is no way i can provide a default value to that column through CQL. I can also not update the value for manager_id later since I need to know the id (Partition key and the values are randomly generated unique values which i don't know) to update the row. Is there any way I can achieve this?
2. Rename this table to all_employee.
I also know that its not allowed to rename a table in cassandra. So I am trying to copy the data of table(employee) to csv and copy from csv to new table (all_employee) and deleting the old table(employee). I am doing this through an automated script with cql queries in it and script works fine but will fail if it gets executed again(Which i can not restrict) since the table employee will not be there once its deleted. Essentially I am looking for "If exists" clause in COPY query which is not supported in cql. Is there any other way I can achieve the outcome?
Please note that the amount of data in the table is very small so performance in not an issue.
For #1
I dont think cassandra support default column . You need to do that from your appliaction. Write some default value every time you insert a row.
For #2
you can check if the table exists before trying to copy from it.
SELECT your_table_name FROM system_schema.tables WHERE keyspace_name='your_keyspace_name';

cassandra and historical data time wise

We have a requirement where we have a relational database table T1 with 20 fields. We capture all changes/updated in this table happening on various fields (commit logs) and ingest/apply those in corresponding table CT1 in Cassandra, i.e. Cassandra table CT1 has exact same schema/fields as T1 (relational DB table).
For Cassandra table CT1 we have additional requirement that we want to capture/store/retrieve all changed values of all fields meaning if Field f1 changed 20 times all its changed-values with the corresponding change-timestamp should be saved. Similarly, if Field f3 changed 100 times all its values should be saved. Note: different fields change at different times and each field changes the variable number of times, meaning one field may change 1000 times a day while some other field may never change at all.
This is some kind of time-series data for each field. So I want to know how to represent such data model efficiently in Cassandra? Another requirement is I want to efficiently retrieve the most recent value of all fields in the table.
For example:
if f1 changed 10 times in a day, for f1 I want its most recent value to be returned. If f2 changed most recently a week back then for f2 that most recent value should be returned, so on for other fields.
You can find more details about time-series storage in Cassandra by reading
this and this articles.
So to find the most recently values easily, you can create the table structure as following:
CREATE TABLE table1_history (
column_name text,
change_time timestamp,
column_value text,
PRIMARY KEY (column_name, change_time),
) WITH CLUSTERING ORDER BY (change_time DESC)
So you can find the latest value with a common selection data from your table.

Query to fill in NULL values from form updates

Working in MS Access 2010 and expecting to receive 1,000s of changes in Excel format that I need to import into a personnel database. I've been tasked with "automating" the update process but could really use some help.
The primary table has 12 fields that could each change for each change form submitted. We have designed a macro to upload the Excel files but some of the fields on the change form will be blank, resulting in incomplete employee records (e.g. original employee record has all 12 records filled in, but change record only has 1).
Is it possible to write a query or macro to fill in the most recent employee record's empty or NULL values with the non-NULL values from the previous entries?
If I understand correctly, you want to retain the value in the 'primary' table if the value in the 'change' table is null. In that case the following should work
UPDATE <primaryTable> INNER JOIN <changeTable> ON <primaryTable>.<keyField> = <changeTable>.<keyField> SET <primaryTable>.<Field1> = nz(<changeTable>.<Field1>,<primaryTable>.<Field1>), <repeat for each field to update>
Just be sure you are dealing with nulls and not empty strings, which is common in Excel imports. In that case you need to either change the empty strings to nulls or use an IIF statement instead of the nz function.

Resources