Alter | Alter library and tool uses simple SQL files | Data Migration library
kandi X-RAY | Alter Summary
kandi X-RAY | Alter Summary
Alter - Beta - Do not use in production =.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Alter
Alter Key Features
Alter Examples and Code Snippets
Community Discussions
Trending Discussions on Alter
QUESTION
I have the following 2 query plans for a particular query (second one was obtained by turning seqscan off):
The cost estimate for the second plan is lower than that for the first, however, pg only chooses the second plan if forced to do so (by turning seqscan off).
What could be causing this behaviour?
EDIT: Updating the question with information requested in a comment:
Output for EXPLAIN (ANALYZE, BUFFERS, VERBOSE)
for query 1 (seqscan on; does not use index). Also viewable at https://explain.depesz.com/s/cGLY:
ANSWER
Answered 2022-Feb-17 at 11:43You should have those two indexes to speed up your query :
QUESTION
Given a regular R function f
, I'd like to be able to create a new function f_debug
that acts just like f
, but lets me keep track of all the assignments to function-local variables that happened inside it.
For example:
...ANSWER
Answered 2022-Feb-08 at 23:18Here's a solution which doesn't return a new function which captures intermediate calculations, but rather calls the given function's code internally. There's some limitations, such as it probably only works with named arguments. Instead of storing the intermediate calculations as an RDS, it attaches them as an attribute.
QUESTION
Say I have a large NumPy array of dtype
int32
ANSWER
Answered 2022-Feb-07 at 00:27
- Is this legitimate? Can you point me to where this feature is documented?
This is legitimate. However, using np.view
(which is equivalent) is better since it is compatible with a static analysers (so it is somehow safer). Indeed, the documentation states:
It’s possible to mutate the
dtype
of an array at runtime. [...] This sort of mutation is not allowed by the types. Users who want to write statically typed code should instead use thenumpy.ndarray.view
method to create a view of the array with a differentdtype
.
- Does it in fact leave the data of the array untouched, i.e. no duplication of the data?
Yes. Since the array is still a view on the same internal memory buffer (a basic byte array). Numpy will just reinterpret it differently (this is directly done the C code of each Numpy computing function).
- What if I want two arrays
a
andb
sharing the same data, but view it as differentdtypes
? [...]
np.view
can be used in this case as you did in your example. However, the result is platform dependent. Indeed, Numpy just reinterpret bytes of memory and theoretically the representation of negative numbers can change from one machine to another. Hopefully, nowadays, all mainstream modern processors use use the two's complement (source). This means that a np.in32
value like -1
will be reinterpreted as 2**32-1 = 4294967295
with a view of type np.uint32
. Positive signed values are unchanged. As long as you are aware of this, this is fine and the behaviour is predictable.
- This can be extended to other
dtypes
, the most extreme of which is probably mixing 32 and 64 bit floats.
Well, put it shortly, this is really like playing fire. In this case this certainly unsafe although it may work on your specific machine. Let us venturing into troubled waters.
First of all, the documentation of np.view
states:
The behavior of the view cannot be predicted just from the superficial appearance of
a
. It also depends on exactly howa
is stored in memory. Therefore ifa
is C-ordered versus fortran-ordered, versus defined as a slice or transpose, etc., the view may give different results.
The thing is Numpy reinterpret the pointer using a C code. Thus, AFAIK, the strict aliasing rule applies. This means that reinterpreting a np.float32
value to a np.float64
cause an undefined behaviour. One reason is that the alignment requirements are not the same for np.float32
(typically 4) and np.float32
(typically 8) and so reading an unaligned np.float64
value from memory can cause a crash on some architecture (eg. POWER) although x86-64 processors support this. Another reason comes from the compiler which can over-optimize the code due to the strict aliasing rule by making wrong assumptions in your case (like a np.float32
value and a np.float64
value cannot overlap in memory so the modification of the view should not change the original array). However, since Numpy is called from CPython and no function calls are inlined from the interpreter (probably not with Cython), this last point should not be a problem (it may be the case be if you use Numba or any JIT though). Note that this is safe to get an np.uint8
view of a np.float32
since it does not break the strict aliasing rule (and the alignment is Ok). This could be useful to efficiently serialize Numpy arrays. The opposite operation is not safe (especially due to the alignment).
Update about last section: a deeper analysis from the Numpy code show that some part of the code like type-conversion functions perform a safe type punning using the memmove
C call, while some other functions like all basic unary operators or binary ones do not appear to do a proper type punning yet! Moreover, such feature is barely tested by users and tricky corner cases are likely to cause weird bugs (especially if you read and write in two views of the same array). Thus, use it at your own risk.
QUESTION
I would like to automatically generate some sort of log of all the database changes that are made via the Django shell in the production environment.
We use schema and data migration scripts to alter the production database and they are version controlled. Therefore if we introduce a bug, it's easy to track it back. But if a developer in the team changes the database via the Django shell which then introduces an issue, at the moment we can only hope that they remember what they did or/and we can find their commands in the Python shell history.
Example. Let's imagine that the following code was executed by a developer in the team via the Python shell:
...ANSWER
Answered 2022-Jan-19 at 09:20You could use django's receiver
annotation.
For example, if you want to detect any call of the save
method, you could do:
QUESTION
I am using VS 2022, .Net 6.0, and trying to build my first app using System.CommandLine
.
Problem: when I build it, I get an error
The name 'CommandHandler' does not exist in the current context
The code I'm trying to build is the sample app from the GitHub site: https://github.com/dotnet/command-line-api/blob/main/docs/Your-first-app-with-System-CommandLine.md , without alteration (I think).
It looks like this:
...ANSWER
Answered 2021-Dec-17 at 23:16Think you're missing a using
line:
QUESTION
I am trying to use a BTreeSet<(String, String, String)>
as a way to create a simple in-memory 'triple store'.
To be precise:
...ANSWER
Answered 2022-Jan-17 at 09:59I'd like to be able to build range-queries for all of the following:
QUESTION
I think I understand how function application works when writing out the steps, but the type signature arithmetic doesn't add up in my head. Apologies for the long prelude (no pun intended).
To bring a specific example, this one is a slightly altered example from Stefan Höck's Idris2 tutorial:
...ANSWER
Answered 2022-Jan-16 at 00:17Yes, that's really all it is. It may make it easier to think about if you write the signature of twice
as
QUESTION
I am working with two dataframes:
df
contains a columnbe/me
for stocks for a 20-year period (on a monthly basis).df2
, a subset ofdf
(with only certain stocks, only for June) contains the columndecile
, created via thepd.qcut()
method for every year in the 20-year period based on an altered version ofdf
'sbe/me
.
Considering the deciles that I created in df2
, I wonder if it's possible to rank df
's be/me
based on df2
's decile
column. In other words, I wonder if it's possible to assign df
's be/me
values to the deciles created in df2
.
Please see dataframes below for a better understanding of the issue:
...ANSWER
Answered 2021-Dec-16 at 16:35To be clear: you want to know for each be/me
value in df
which decile it would have fallen into if that value had been in df2
? I see two cases:
If
df2
covers the whole month of June (as you wrote), I am afraid there is no answer to that question: each day in the month will have decile bins with different edges (since you are doing agroupby('date')
ondf2
). The samebe/me
value indf
could belong to different deciles indf2
depending on the day in June you consider.If
df2
actually covers only one day in June (as your example above seems to indicate:2020-06-30
), then you have one well defined set of decile bins.
In case 2), you could do that:
QUESTION
I've been working in quite a number of statically-typed programming languages (C++, Haskell, ...), but am relatively new to Rust.
I often end up writing code like this:
...ANSWER
Answered 2021-Dec-16 at 12:19You can accomplish this by making your own trait that takes the other traits as a bound, then add a blanket implementation for it:
QUESTION
We have been trying to create many roles and users in one of the databases. At one point I came across this issue that I am finding it hard to reproduce.
It is reproducible within the database but when I create a new database and try the same it isn't happening :(
ALTER TABLE public.table_name OWNER TO role_name;
Usually, after we run this query. The table_name
will be owned
by the role_name
role/user.
After running the above query if we run the below query:
...ANSWER
Answered 2021-Nov-19 at 01:06the role can be the owner and still not have select, insert, update, delete privilege?
Yes. The manual:
An object's owner can choose to revoke their own ordinary privileges, for example to make a table read-only for themselves as well as others. But owners are always treated as holding all grant options, so they can always re-grant their own privileges.
And a superuser can do anything that the owner can do.
Tricky detail: The owner (or a superuser) can REVOKE
privileges from himself (the owner). If ownership then changes hands, the new owner inherits the set of privileges that the previous owner had - plus any privileges the new owner might already have held. So the union of the previous privileges of the role and privileges of the owner. Those are then the new privileges of the owner.
If ownership again changes hands, the whole set of privileges is passed on! The previous owner loses all privileges he has held directly.
But any role can inherit additional privileges via membership in another role or via PUBLIC
privileges.
Closely related:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Alter
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page