Big Query Issue: Query Failed with Request was blocked to protect the systems operation - google-bigquery

Please can you advise why we are seeing this error for a query we were previously able to run?
Error: Request was blocked to protect the systems operation. Please contact
We have tried running this query several times
Writing an email to the address returned:
you may not have permission to post messages to the group
I get this message when querying a 12TB table with around 25B rows. The query I am trying to run is selecting from one table, with a cross join on another table where two values in table A are between two values in table B, and I am doing a group by on two field. As mentioned before, all was working fine for the last 15 months until yesterday

To address your points in turn :
1 - Copy from shollyman's comment concerning your error:
The short answer: a cross join involving a table of that size is problematic given any reasonably sized second table. The message indicates that the BQ team is explicitly blocking this query due to its behavior.
2- I think you couldn't email at the address because it's a Google Group. You need to register to these first. There should be a way for you to do so. It's also possible (notice the error message says "may") that your message just needs to be accepted by a member of the group before it goes through.
3- If your issue is recent, it's most likely because you recently added enough data to one of your tables to make the cross join too big.

Related

Users updating same row at the same time SQL Server

I want to create a SQL Server table that has a Department and a Maximum Capacity columns (assume 10 for this scenario). When users add them selves to a department the system will check the current assignment count (assume 9 for this scenario) in the department and compare it to the maximum value. If it is below the maximum, they will be added.
The issue is this: what if two users submit at the same time and the when the code retrieves the current assignment count it will be 9 for both. One user updates the row sooner so now its 10 but the other user has already retrieved the previous value before the update (9) and so both are valid when compared and we end up with 11 users in the department.
Is this even possible and how can one solve it?
The answer to your problem lies in understanding "Database Concurrency" and then choosing the correct solution to your specific scenario.
It too large a topic to cover in a single SO answer so I would recommend doing some reading and coming back with specific questions.
However in simple form you either block the assignments out to the first person who tries to obtain them (pessimistic locking), or you throw an error after someone tries to assign over the limit (optimistic locking).
In the pessimistic case you then need ways to unblock them if the user fails to complete the transaction e.g. a timeout. A bit like on a ticket booking website it says "These tickets are being held for you for the next 10 minutes, you must complete your booking within that time else you may lose them".
And when you're down to the last few positions you are going to be turning everyone after the first away... no other way around it if you require this level of locking. (Well you could then create a waiting list, but that's another issue in itself).

Access Query / Report - Error: This expression is typed incorrectly or it is too complex to be evaluated on calculated field

So after reading 9 posts about the same error on Stack I didn't really find an answer to my problem, hence me posting this question.
So in my Access I have a query that inherits from several other queries. With this query a User can get information with a certain Date range. This data is put in a report where the records are shown and internally (in the report) some calculation is done of the record fields.
The problem is, when A user wants data until the date 2016-4-22 the report shows up fine. Though when the User wants data until the date 2016-4-30 (from day 23 and on it just gives the same errors) the report tries to load but after a while fails with the error:
This expression is typed incorrectly or it is too complex to be evaluated
So this made me test a few things which I have list down below:
First I thought the Query itself or the given WHERE clause were corrupted / not good so I put the Report recordsource with the WHERE clause in a separate test query and executed it. This all worked fine (no errors).
This made me believe that perhaps a single record was corrupted so I went to the date from which on it gave the error (2016-4-23) and checked this record. Nothing weird was found.
Then I thought it could be some field on the report that was giving the error so I removed several fields and after removing a few Calculated Sum(total) fields the error disappeared.
So I created another query and did the Sum in this query as well based on my created test query - this gave the same error.
After these tests I was pretty sure that perhaps the calculated data was just too much to calculate. I also copied the queries data into Excel and did a SUM of the field there as well. The outcome was roughly 15 million. I can hardly imagine that a number of 15 million is too complex to be evaluated...
Besides that, I also tried to create another SUM query on the specific field but with the date based on 2016-4-22 (so the one that initially DID work). But now it also givers the error on this date... So there goes my theory..
Anyone has a clue what is going wrong?
The 'base' query in question is:
SELECT qryOHW6Verdicht.*
, CStr([nummer] & "." & [qryOHW6Verdicht].[positie]) AS NummerPos
, [ArbeidTot]+[MateriaalTot]+[UitbesteedTot] AS Kosten
, CDbl([AangenomenprijsPositie])+CDbl([MeerwerkPrijsPositie]) AS OpdrachtSom
, IIf([nacalculatie],[Kosten],IIf(IsNull([kostenverwacht]),(100-[otwinstpercentage])/100*[opdrachtsom],[kostenverwacht])) AS VerwachteKosten
, IIf([nacalculatie],[kosten],IIf([Kosten]<[VerwachteKosten],[Opdrachtsom]-[VerwachteKosten],[Opdrachtsom]-[Kosten])) AS VerwachteWinst
, [Kosten]-[VerkoopTot] AS WaardeOHW
, DatePart("yyyy",[gereeddatum]) AS GereedJaar
, [OtOverhead]*[VerkoopTot]/100 AS Overhead
, qryVCBoekingenVerdicht.KostenVerwacht
FROM qryOHW6Verdicht LEFT JOIN qryVCBoekingenVerdicht
ON (qryOHW6Verdicht.[Positie] = qryVCBoekingenVerdicht.[Positie])
AND (qryOHW6Verdicht.[Nummer] = qryVCBoekingenVerdicht.[Offerte])
The report opens with the previous query as recordsource and with this WHERE filter:
1=1 AND (Gereeddatum is null OR Gereeddatum>=#2016-4-30# )
AND Project IS NULL AND NOT (WaardeOHW=0 AND Kosten=0) AND GarantieOrder=0
In the report I got a few Calculated fields and one of them that goes wrong is:
=Sum([OpdrachtSom])

Can't get MS Access SQL Statement W/ Nested Joins to Function Properly

Let me start by saying, I have scoured the web for help with this, tried figuring it out with a professor and used a Database Systems text book and have still not gotten this to work properly. I am attempting to finish this database as my final project for a DB management course that I'm taking, but it is also for real world use at work. My team at work currently creates access to a clinical system for end users. When we receive a request form it includes a "ServiceNow Position" (Column A) and a "ServiceNow Role" (Column B). My team has to then reference a spreadsheet, which I've attempted to attach, to find out what this correlates to in the clinical system (Column C). The row of the spreadsheet also dictates what, if any, user orgs (Column F) and user groups (column G) that the user account receives. I'm including a screenshot of the relationship between the tables prior to my modifications to the SQL statement, as once the outer joins are in place, the relationships don't illustrate.
The idea here is that I will always be given the ServiceNow role and position, it will always correlate to a row on the "Cerner_HNA_Positions" table. I will NOT necessarily always have User_Group or Organizations, though when I do have them, I may have up to 2 and 4 respectively.
My goal is to get a query that works properly, and then create a form on top of this so that who ever is working account creations can insert the ServiceNow Position and Role and have returned what the "Cerner_HNA_Positions.HNA_Position" is and any correlated User Groups and Organizations. The following is the closest SQL statement that I've gotten to function without a syntax error. However, this is returning every HNA_User_Group and HNA_Org, even though the row for HNA_Position that it returns does not have any HNA_User_Group's or Orgs assigned. I'm sure this is something to do with the fact that I've done a left join, but my goal in this was to ensure that I see the HNA_Position. Can anyone help me with this?
SELECT DISTINCT Cerner_HNA_Positions.HNA_Position,
Cerner_HNA_Positions.Like_User,
Cerner_HNA_Positions.Physician,
Cerner_HNA_Positions.Add_Resources,
Cerner_HNA_User_Groups.*,
Cerner_HNA_Organizations.*,
[Service Now Position Name].Service_Now_Position,
[ServiceNow Role].Service_Now_Role
FROM Cerner_HNA_User_Groups,
Cerner_HNA_Organizations,
[ServiceNow Role]
INNER JOIN ([Service Now Position Name]
INNER JOIN Cerner_HNA_Positions
ON [Service Now Position Name].Service_Now_Position_ID =
Cerner_HNA_Positions.Service_Now_Position_ID)
ON [ServiceNow Role].Service_Now_Role_ID =
Cerner_HNA_Positions.Service_Now_Role_ID
WHERE ((([Service Now Position Name].Service_Now_Position)="CIS - PowerChart")
AND (([ServiceNow Role].Service_Now_Role)="Resident"));
Spreadsheet referenced above: https://www.dropbox.com/s/1vreampypo17lcd/Positions_Roles%20Sheet.xlsx?dl=0

sql update multiple rows with multi join subselect

This is an updated part 2 of a question I asked earlier. I'm trying to make the following update, but this query does not actually seem to do anything.
UPDATE u
SET graduation_class_id = gc.graduation_class_id
FROM [user] u
JOIN graduation_class gc
ON u.graduation_class_id = gc.graduation_class_id
JOIN graduation_term gt
ON gt.graduation_year_id = gc.graduation_year_id
TABLE SCHEMA
**user
user_id
graduation_class_id
**graduation_class
graduation_class_id
graduation_year_id
**graduation_term
graduation_term_id
graduation_year_id
The goal is to get the matching graduation_class_id value into the user table. I've been told this won't work because the match won't be found unless the user already has the matching graduation_class_id. That is a problem, because I'm trying to actually get the proper one in there!
This idea is fundamentally doomed to fail. You're trying to get the SQL server to link a graduation class to a user by itself, despite the SQL server not having information on which graduation class should be linked to the user. Unless you have some data somewhere (in user, in graduation_class, in some other table) that links a user_id to the graduation term, class, or year (or someone manually telling SQL which data match up), SQL can't magically do that job for you.

Use a Query from the Destination db to limit OLE DB Source task in SSIS 2008

All,
I have a package that I'm building as a data importer so I can copy sets of data from my production environment and develop on another instance.
I have two tables that contain header and detail rows for service tickets. Those service tickets are tied back to orders.
I am pulling the service tickets from a certain time window, however, the originating orders fall outside of the date range that I'm pulling for the tickets.
I want to be able to take the following steps in an SSIS package:
Import the header and detail rows within the given date range from prod to dev
Select the relevant order numbers from dev tables
Use the list of order numbers to import only the relevant orders from prod
I poked through other answers and couldn't find answers that addressed this directly, so I apologize if there is an answer out there and I missed it. I may not have been asking the question correctly. I'm assuming that I would need to pull those order numbers into a temp table or variable in order to apply them as a filter.
As I write this, it just crossed my mind to use a join on the source system with the ticket to order tables and still use the date range to limit, but I'm still posting the question to see if anyone has dealt with this before.
Your steps are already fairly clear, are you asking how to actually implement them? It looks like you can do all three steps by using SELECT statements in your data sources:
Build a SELECT statement dynamically with the correct dates to use in your data source. The dates could be programmatically generated in a script task, or saved in a database table and populated into variables. Then you copy the data across to the dev system.
Run a SELECT statement in the dev system that returns the order numbers, and copy the results to a table in the prod database.
Run a SELECT statement in the prod database that joins on the table from step 2 and copy the results back to dev.
An alternative to the table in steps 2 and 3 would be a lookup transformation, but if you have a large number of rows then using a table will probably be faster.